What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator()(const T and val ) {
out< } }; struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return 10*(1+(start++ %3)); } }; int main() { vector generate(v1.begin(), v1.end(), Sequence(1)); unique(v1.begin(),v1.end()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
B. 20 30 10
C. 30 10 20
D. compilation error
What happens when you attempt to compile and run the following code? Choose all possible answers.
#include
using namespace std;
template
class A {
T_v;
public:
A() {}
A(T v): _v(v){}
friend ostream and operator<<(ostream and c, const A
c< } }; int main() { A
What will happen when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main ()
{
vector
deque
for(int i=0; i<5; i++)
{
v1.push_back(i);v1.push_front(i);
d1.push_back(i);d1.push_front(i);
}
for(int i=0; i { cout< } cout< return 0; } What will be its output:
B. runtime exception
C. compilation error due to line 11
D. compilation error due to line 12
What happens when you attempt to compile and run the following code? #include
#include
#include
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 and b) const { return a == b.a; }
};
bool compare(const A and a, const A and b) { return a == b; }
int main () {
int t[] = {1,2,3,3,5,1,2,4,4,5};
vector v (t,t+10);
vector::iterator it = v.begin();
while ( (it = adjacent_find (it, v.end(), compare)) != v.end()) {
cout< } cout<< endl; return 0; }
B. program outputs: 2 7
C. program outputs: 3 8
D. compilation error
E. program will run forever
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) { out< }; bool Compare(char a, char b) { return tolower(a) < tolower(b);} int main() { char s[]={"qwerty"}; char t1[]={"ert"}; char t2[]={"ERT"}; sort(s, s+6); cout< return 0; } Program outputs:
B. 0 1
C. 1 0
D. 1 1
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) { out< template T start; T step; Sequence(T start, T step):start(start), step(step){} T operator()() { T v = start; start+=step; return v; } }; bool Less(float a, float b) { return int(a) int main() { float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13}; vector stable_sort(v1.begin(), v1.end(), Less); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
B. 1.13 1.32 1.66 1.96 2.28 2.3 2.62 2.98 3.64 3.94
C. compilation error
D. 3.94 3.64 2.98 2.62 2.3 2.28 1.96 1.66 1.32 1.13
E. the exact output is impossible to determine
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A
{
int a,b;
public:
A and operator =(const A and c) { a = c.a; return *this;}
A():a(0),b(0){}
void setA(int a) {this?>a = a;} void setB(int b) {this?>b = b;}
int getA() {return a;} int getB() {return b;}
};
int main ()
{
vectorv;
A a;
a.setA(10); a.setB(11);
v.push_back(a);
A b = v.front(); v.pop_back();
cout< return 0; }
B. compilation error
C. program outputs 0 10
D. program outputs 10 0
E. program outputs 11 0
What happens when you attempt to compile and run the following code? Choose all that apply.
#include
#include
#include
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) {out< int main () { int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; fstream f("test.out", ios::trunc|ios::out); list for_each(l.begin(), l.end(), Out f.close(); f.open("test.out"); for( ; f.good() ; ) { int i; f>>i; cout< } f.close(); return 0; }
B. file test.out will be truncated
C. file test.out will be opened for reading
D. no file will be created nor opened
E. program will display sequence 1 2 3 4 5 6 7 8 9 10
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
#include
using namespace std;
template
public:
B(T v):val(v){}
T getV() const {return val;} };
template template ostream and out; Out(ostream and o): out(o){} void operator() (const T and val ) { out< string tolower(const string and s) { string tmp(s); for(unsigned i = 0; i< tmp.size(); ++i){ tmp[i] = tolower(tmp[i]); } return tmp; } bool Less(const B int main() { string t[]={"aaa","bbb","Aaa", "Bbb","aAa","bBb","aaA","bbB"}; vector > v1; v1.assign(t, t+8); stable_sort(v1.begin(), v1.end(), Less); for_each(v1.begin(), v1.end(), Out >(cout));cout< return 0; } Program outputs:
B. Aaa aaa aAa aaA bbb Bbb bbB bBb
C. aaa Aaa aAa aaA bbb Bbb bBb bbB
D. the exact output is impossible to determine
What happens when you attempt to compile and run the following code? #include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator()(const T and val ) { out< }; struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; struct Odd { bool operator()(int v) { return v%2==0; } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); stable_partition(v1.begin(),v1.end(), Odd()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
B. 5 7 3 9 1 10 2 8 4 6
C. 10 2 8 4 6 5 7 3 9 1
D. 4 6 8 10 2 7 5 3 1 9
E. 2 4 6 8 10 1 3 5 7 9
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPP-22-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.