C++ Institute C++ Certified Professional Programmer CPP Question # 66 Topic 7 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 66 Topic 7 Discussion

CPP Exam Topic 7 Question 66 Discussion:
Question #: 66
Topic #: 7

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

#include

#include <algorithm>

#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;

}


A.

it will compile successfully


B.

it will display Found!


C.

it will display Not found!


D.

it will not compile successfully


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.