C++ Institute C++ Certified Professional Programmer CPP Question # 50 Topic 6 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 50 Topic 6 Discussion

CPP Exam Topic 6 Question 50 Discussion:
Question #: 50
Topic #: 6

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

#include

using namespace std;

class C {

public:

int _c;

C():_c(0){}

C(int c) { _c = c;}

C operator+=(C & b) {

C tmp; tmp._c = _c+b._c;

return tmp;

} };

ostream & operator<<(ostream & c, const C & v) {

c<

template

class A {

T_v;

public:

A() {}

A(T v): _v(v){}

T getV() { return _v; }

void add(T & a) { _v+=a; }

};

int main()

{

A b(2);

Aa (5);

a.add(C());

cout << a.getV() <

return 0;

}


A.

program will display:5


B.

program will not compile


C.

program will compile


D.

program will cause runtime exception


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.