NO.1 What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
struct Add {
int operator()(int & a, int & b) {
return a+b;
}
};
int main() {
int t[]={1,2,3,4,5,6,7,8,9,10};
vector<int> v1(t, t+10);
vector<int> v2(10);
transform(v1.begin(), v1.end(), v2.begin(), bind1st(1,Add()));
for_each(v2.rbegin(), v2.rend(), Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:
A. 11 10 9 8 7 6 5 4 3 2
B. 2 3 4 5 6 7 8 9 10 11
C. 10 9 8 7 6 5 4 3 2 1
D. compilation error
E. 1 2 3 4 5 6 7 8 9 10
Answer: D
CPP Success
NO.2 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. compilation error
B. program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2
C. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
D. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2
E. runtime exception
Answer: D
Every day is new beginning; we will have a good mood. Hot and outstanding IT certification will be a good beginning for your IT career road. C++ Institute CPP Exam Simulator current exam content will be a strong helper for you. If you want to realize your dream and get a certification, BraindumpsQA provide the best valid C++ Institute CPP Exam Simulator current exam content materials to help you pass tests. And you will have a great progress in a short time.
Exam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
CPP Exam Simulator Total Q&A: 230 Questions and Answers
Last Update: 2017-03-27
CPP Reliable Test Simulator Free Detail: CPP Exam Simulator
Would you like to register C++ Institute CPP Exam Simulator certification test? Would you like to obtain CPP Exam Simulator certificate? Without having enough time to prepare for the exam, what should you do to pass your exam? In fact, there are techniques that can help. Even if you have a very difficult time preparing for the exam, you also can pass your exam successfully. How do you do that? The method is very simple, that is to use BraindumpsQA C++ Institute CPP Exam Simulator dumps to prepare for your exam.
CPP Free Demo Download: http://www.braindumpsqa.com/CPP_braindumps.html