NO.1 What happens when you attempt to compile and run the following code?
#include <list>
#include <iostream>
using namespace std;
template<class T> void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
class A {
int a;
public:
A(int a):a(a){}
operator int () const { return a;}int getA() const { return a;}
};
int main() {
int t1[] ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
list<A> l1(t1, t1 + 10);
list<A> l2(l1);
l2.reverse(); l1.splice(l1.end(),l2);
l1.pop_back();l1.unique();
print(l1.begin(), l1.end()); cout<<endl;
return 0;
}
A. runtime exception
B. compilation error
C. program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2
D. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
E. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2
Answer: E
CPP Discount
NO.2 What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
class A {
int a;
public:
A(int a) : a(a) {}
int getA() const { return a; } void setA(int a) { this?>a = a; }
bool operator==(const A & b) const { return a == b.a; }
};
bool compare(const A & a, const A & b) { return a == b; }
int main () {
int t[] = {1,2,3,3,5,1,2,4,4,5};
vector<A> v (t,t+10);
vector<A>::iterator it = v.begin();
while ( (it = adjacent_find (it, v.end(), compare)) != v.end()) {
cout<<it?v.begin()<<" ";it++;
}
cout<< endl;
return 0;
A. program outputs: 2 3
B. program will run forever
C. compilation error
D. program outputs: 3 8
E. program outputs: 2 7
Answer: E
CPP Updated
Pass4Test have a professional IT team to do research for practice questions and answers of the C++ Institute CPP Updated CBT exam certification exam. They provide a very effective training tools and online services for your. If you want to buy Pass4Test products, Pass4Test will provide you with the latest, the best quality and very detailed training materials as well as a very accurate exam practice questions and answers to be fully prepared for you to participate in the C++ Institute certification CPP Updated CBT exam. Safely use the questions provided by Pass4Test's products. Selecting the Pass4Test is equal to be 100% passing the exam.
Exam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
CPP Updated CBT Total Q&A: 230 Questions and Answers
Last Update: 2017-03-30
CPP Reliable Practice Materials Detail: CPP Updated CBT
Only to find ways to success, do not make excuses for failure. To pass the C++ Institute CPP Updated CBT exam, in fact, is not so difficult, the key is what method you use. Pass4Test's C++ Institute CPP Updated CBT exam training materials is a good choice. It will help us to pass the exam successfully. This is the best shortcut to success. Everyone has the potential to succeed, the key is what kind of choice you have.
CPP Free Demo Download: http://www.pass4test.com/CPP.html
没有评论:
发表评论