Black Friday Special 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

C++ Certified Professional Programmer CPP C++ Institute Study Notes

Page: 9 / 9
Total 228 questions

C++ Certified Professional Programmer Questions and Answers

Question 33

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

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

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

void operator() (const T & val ) { out<

int main() {

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

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

deque d1(t, t+10);

set s1(t, t+10);

sort(d1.begin(), d1.end());

cout<<includes(s1.begin(),s1.end(), t1,t1+4)<<" "<

<

return 0;

}

Program outputs:

Options:

A.

1 1

B.

1 0

C.

0 1

D.

0 0

Question 34

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

#include

#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 & b) const { return a

};

class F {

A val;

public:

F(A & v):val(v){}

bool operator() (A & v) {

if (v.getA() == val.getA()) return true;

return false;

}

};

int main() {

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

vector v1(t, t + 10);

set s1(t, t + 10);

A a(6); F f(a);

find_if(s1.begin(), s1.end(), f);

if (find_if(v1.begin(), v1.end(), f) !=v1.end()) {

cout<<"Found!\n";

} else {

cout<<"Not found!\n";

}

return 0;

}

Options:

A.

it will compile successfully

B.

it will display Found!

C.

it will display Not found!

D.

it will not compile successfully

Page: 9 / 9
Total 228 questions