Weekend Sale Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: bigdisc65

Vce CPP Questions Latest

Page: 4 / 8
Question 16

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

#include

using namespace std;

class A

{

int a;

public:

A(int a) {this?>a = a; c++;}

A(const A & a) {this?>a = a.a; c++;}

~A() { c??;}

static int c;

};

int A::c(0);

int main ()

{

A* t[] = {new A(1), new A(2), new A(3),new A(4), new A(5)};

vectorv1(t, t+10);

dequed1(v1.begin(), v1.end());

d1.clear();

v1.clear();

cout<<A::c<< endl;

return 0;

}

Options:

A.

there are 15 A objects created,

B.

there are 5 A objects created,

C.

for all object A the destructor is called

D.

program will display 5

Question 17

What happens when you attempt to compile and run the following code?

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v=0):val(v){}

int getV() const {return val;}

operator int () const { return val;} };

ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;}

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<<val<<" "; } };

struct Add {

B operator()(B & a, B & b) { return a+b; } };

int main() {

B t[]={1,2,3,4,5,6,7,8,9,10};

vector v1(t, t+10);

vector v2(10);

transform(v1.begin(), v1.end(), v2.begin(), bind2nd(Add(),1));

for_each(v2.rbegin(), v2.rend(), Out(cout));cout<<endl;

return 0;

}

Program outputs:

Options:

A.

1 2 3 4 5 6 7 8 9 10

B.

2 3 4 5 6 7 8 9 10 11

C.

10 9 8 7 6 5 4 3 2 1

D.

11 10 9 8 7 6 5 4 3 2

E.

compilation error

Question 18

What happens when you attempt to compile and run the following code?

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;} bool operator < (const B & v) const { return val

ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;}

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<<val<<" "; } };

int main() {

B t1[]={3,2,4,1,5};

int t2[]={5,6,8,2,1};

vector v1(10,0);

sort(t1, t1+5);

sort(t2, t2+5);

set_union(t1,t1+5,t2,t2+5,v1.begin());

for_each(v1.begin(), v1.end(), Out(cout));cout<<endl;

return 0;

}

Program outputs:

Options:

A.

3 2 4 1 5 6 8 2 1 0

B.

1 2 3 4 5 6 8 2 1 0

C.

1 1 2 2 3 4 5 5 6 8

D.

1 2 3 4 5 6 8 0 0 0

E.

compilation error

Question 19

What happens when you attempt to compile and run the following code?

#include

#include

#include

using namespace std;

int main () {

int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};

vector v (t,t+15);

vector::iterator it = search_n(v.begin(), v.end(), 4, 2);

cout<< it?v.begin()<<endl;

return 0;

}

Program outputs:

Options:

A.

10

B.

3

C.

1

D.

15

E.

compilation error

Page: 4 / 8
Exam Code: CPP
Exam Name: C++ Certified Professional Programmer
Last Update: May 18, 2024
Questions: 228
CPP pdf

CPP PDF

$28  $80
CPP Engine

CPP Testing Engine

$33.25  $95
CPP PDF + Engine

CPP PDF + Testing Engine

$45.5  $130