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. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
C. program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2
D. compilation error
E. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2
Answer: E
CPP Practical CPP Registration
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 will run forever
B. program outputs: 3 8
C. compilation error
D. program outputs: 2 3
E. program outputs: 2 7
Answer: E
CPP Provider
Are you satisfied with your present job? Are you satisfied with what you are doing? Do you want to improve yourself? To master some useful skills is helpful to you. Now that you choose to work in the IT industry, you must register IT certification test and get the IT certificate which will help you to upgrade yourself. What's more important, you can prove that you have mastered greater skills. And then, to take C++ Institute CPP New Exam Camp File exam can help you to express your desire. Don't worry. BraindumpStudy will help you to find what you need in the exam and our dumps must help you to obtain CPP New Exam Camp File certificate.
Exam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
CPP New Exam Camp File Total Q&A: 230 Questions and Answers
Last Update: 2017-04-24
CPP New Study Questions Free Download Detail: CPP New Exam Camp File
BraindumpStudy's training materials can test your knowledge in preparing for the exam, and can evaluate your performance within a fixed time. The instructions given to you for your weak link, so that you can prepare for the exam better. The BraindumpStudy's C++ Institute CPP New Exam Camp File exam training materials introduce you many themes that have different logic. So that you can learn the various technologies and subjects. We guarantee that our training materials has tested through the practice. BraindumpStudy have done enough to prepare for your exam. Our material is comprehensive, and the price is reasonable.
CPP Free Demo Download: http://www.braindumpstudy.com/CPP_braindumps.html
没有评论:
发表评论