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

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

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

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

#include

#include

using namespace std;

class A

{

int a,b;

public:

A & operator =(const A & c) { a = c.a; return *this;}

A():a(0),b(0){}

void setA(int a) {this?>a = a;} void setB(int b) {this?>b = b;}

int getA() {return a;} int getB() {return b;}

};

int main ()

{

vectorv;

A a;

a.setA(10); a.setB(11);

v.push_back(a);

A b = v.front(); v.pop_back();

cout<

return 0;

}


A.

program outputs 11 10


B.

compilation error


C.

program outputs 0 10


D.

program outputs 10 0


E.

program outputs 11 0


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.