Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA Topic 2 Question 83 Discussion

Actual exam question for C++ Institute's CPA exam
Question #: 83
Topic #: 2
[All CPA Questions]

Which code, inserted at line 10, generate the output "50"?

#include

using namespace std;

class Base {

int age;

public:

Base () {

age=5;

};

//insert code here

void Print() { cout << age;}

};

void setAge(Base &ob) {ob.age = 0;}

int main () {

Base a;

a.Print();

setAge(a);

a.Print();

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Tish
10 months ago
So, the correct answer must be B) compilation error.
upvoted 0 times
...
Tonja
10 months ago
Oh, then it might give a compilation error.
upvoted 0 times
...
Luisa
10 months ago
But it looks like there is no declaration for 's4'.
upvoted 0 times
...
Lynda
10 months ago
I agree, the code seems fine to me.
upvoted 0 times
...
Leatha
10 months ago
I think it will compile successfully.
upvoted 0 times
...
Dylan
10 months ago
I'm not sure but I think it will print ''123''.
upvoted 0 times
...
Abel
11 months ago
I think it will print ''132''.
upvoted 0 times
...
Flo
11 months ago
I believe it will print ''021''.
upvoted 0 times
...
Tish
12 months ago
I think it will print a compilation error.
upvoted 0 times
...

Save Cancel