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: 2 7
B. compilation error
C. program outputs: 3 8
D. program will run forever
E. program outputs: 2 3
Answer: A
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. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2
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. runtime exception
E. program outputs: 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
Answer: A
CPP Trustworthy CPP Complete
New CPP Exam Format is a website specifically provide the certification exam information sources for IT professionals. Through many reflects from people who have purchase New CPP Exam Format's products, New CPP Exam Format is proved to be the best website to provide the source of information about certification exam. The product of New CPP Exam Format is a very reliable training tool for you. The answers of the exam exercises provided by New CPP Exam Format is very accurate. Our New CPP Exam Format's senior experts are continuing to enhance the quality of our training materials.
Exam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
New CPP Exam Format Total Q&A: 230 Questions and Answers
Last Update: 2017-03-27
CPP Latest Vce Exam Simulator Detail: New CPP Exam Format
The objective of ITCertKey is help customer get the certification with C++ Institute latest dumps pdf. As long as you remember the key points of New CPP Exam Format test answers and practice exam pdf skillfully, you have no problem to pass the exam. If you lose exam with our New CPP Exam Format dumps torrent, we promise you full refund to reduce your loss.
CPP Free Demo Download: http://www.itcertkey.com/CPP_braindumps.html
沒有留言:
張貼留言