C++ Institute C++ Certified Professional Programmer CPP Question # 20 Topic 3 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 20 Topic 3 Discussion

CPP Exam Topic 3 Question 20 Discussion:
Question #: 20
Topic #: 3

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

#include

using namespace std;

template

class A {

T_v;

public:

A() {}

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

T getV() { return _v; }

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

template

U get(U a) {

return (U)(_v);

}

};

int main()

{

A a(1);

a.add(10);

cout.setf( ios::showpoint);

cout << a.getV() << " " << a.get(1.0)<

return 0;

}


A.

program will display: 11 11


B.

program will not compile


C.

program will display: 11.0000 11


D.

program will display: 11 11.000


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.