Exam4Training

cout << padd?

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

#include <iostream>

using namespace std;

class Test {

float i,j;

};

class Add {

public:

int x,y;

Add (int a=3, int b=3) { x=a; y=b; }

int result() { return x+y;}

};

int main () {

Test test;

Add * padd;

padd = &test;

cout << padd?>result();

return 0;

}
A . It prints: 6
B . It prints: 9
C . Compilation error
D . It prints: 33

Answer: C

Exit mobile version