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. 1 2 3 4 5 6 7 8 9 10
B. 11 10 9 8 7 6 5 4 3 2
C. compilation error
D. 2 3 4 5 6 7 8 9 10 11
E. 10 9 8 7 6 5 4 3 2 1
Answer: C
CPP Collection
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 9 8 7 6 5 4 3 2 1
D. runtime exception
E. program outputs: 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2
Answer: A
CPP Time
Pass4Test is a website to provide a targeted training for C++ Institute certification CPP Valid Exam Pass4Sure exam. Pass4Test is also a website which can not only make your expertise to get promoted, but also help you pass C++ Institute certification CPP Valid Exam Pass4Sure exam for just one time. The training materials of Pass4Test are developed by many IT experts' continuously using their experience and knowledge to study, and the quality is very good and have very high accuracy. Once you select our Pass4Test, we can not only help you pass C++ Institute certification CPP Valid Exam Pass4Sure exam and consolidate their IT expertise, but also have a one-year free after-sale Update Service.
Exam Name: C++ Certified Professional Programmer
One year free update, No help, Full refund!
CPP Valid Exam Pass4Sure Total Q&A: 230 Questions and Answers
Last Update: 2017-03-28
CPP Valid Test Sims Detail: CPP Valid Exam Pass4Sure
As for C++ Institute CPP Valid Exam Pass4Sure exam, it is the most difficult to pass. But, as long as you believe in Pass4Test, everything is ok. Pass4Test C++ Institute CPP Valid Exam Pass4Sure exam simulations contain the most accurate questions and answers. If you don't believe our C++ Institute CPP Valid Exam Pass4Sure certification training, you can go to our Pass4Test. You can find pdf real questions and answers and download it. And the purchase rate is unbelievably high every day. By choosing it, pass rate is 100%. Hurry up! Don't hesitate to add our C++ Institute CPP Valid Exam Pass4Sure dumps torrent to your shopping cart.
CPP Free Demo Download: http://www.pass4test.com/CPP.html
没有评论:
发表评论