What happens when you attempt to compile and run the following code?
#include
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;
}
Suggested Answer: C
Get Premium CPA-21-02 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
10 comments · newest first
LI
Lindsay
3 hours ago
I think it will cause a compilation error.
MA
Marta
5 days ago
Definitely a compilation error, no doubt about it!
TA
Taryn
10 days ago
I thought it would print 6, but now I'm confused.
JI
Jill
16 days ago
Wait, are you sure? I thought it might print something.
TR
Tresa
21 days ago
Totally agree, that's a compilation error.
GE
Gearldine
26 days ago
It won't compile, wrong pointer type!
LE
Lemuel
1 month ago
I think it will definitely cause a compilation error. The types just don't match up, right?
BI
Billi
1 month ago
I feel like it should print something, but I can't remember if it's 6 or 9. The pointer assignment seems off though.
ST
Stevie
1 month ago
I remember something about pointers, but I'm not sure if the code will compile. It feels like it might be similar to a practice question we did.
VE
Vesta
2 months ago
I think there's a compilation error because `padd` is a pointer to `Add`, but it's being assigned an instance of `Test`.