NO.1 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: 3 8
B. program will run forever
C. compilation error
D. program outputs: 2 3
E. program outputs: 2 7
Answer: E
CPP Quality CPP Details
NO.2 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. compilation error
B. 10 9 8 7 6 5 4 3 2 1
C. 11 10 9 8 7 6 5 4 3 2
D. 1 2 3 4 5 6 7 8 9 10
E. 2 3 4 5 6 7 8 9 10 11
Answer: A
CPP Overviews CPP Topic
Pass your CPP Reliable Dumps Files exam certification with CPP Reliable Dumps Files reliable test. The BraindumpsQA CPP Reliable Dumps Files practice material can guarantee you success at your first try.When you choose CPP Reliable Dumps Files updated dumps, you will enjoy instant downloads and get your CPP Reliable Dumps Files study files the moment you have paid for them. In addition, the update is frequent so that you can get the CPP Reliable Dumps Files latest information for preparation.
Exam Code: CPPExam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
CPP Reliable Dumps Files Total Q&A: 230 Questions and Answers
Last Update: 2017-04-10
CPP Reliable Exam Dumps File Detail: CPP Reliable Dumps Files
C++ Institute certification CPP Reliable Dumps Files exams has become more and more popular in the fiercely competitive IT industry. Although more and more people sign up to attend this examination of, the official did not reduce its difficulty and it is still difficult to pass the exam. After all, this is an authoritative test to inspect the computer professional knowledge and information technology ability. In order to pass the C++ Institute certification CPP Reliable Dumps Files exam, generally, many people need to spend a lot of time and effort to review.
CPP Free Demo Download: http://www.braindumpsqa.com/CPP_braindumps.html