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 4 Question 88 Discussion

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

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

#include

#include

using namespace std;

class A {

public:

int x;

};

class B : public A {

public:

B() { x=1;}

B(int x) {this?>x = x;}

};

int main () {

B c1;

B c2(10);

cout << c1.x;

cout << c2.x;

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Keneth
11 months ago
Haha, this code is like a linguistic tug-of-war! I think option B is the winner here.
upvoted 0 times
Venita
10 months ago
Yeah, the swap function switches the positions of the strings in the array.
upvoted 0 times
...
Whitley
10 months ago
I agree, option B is the correct answer.
upvoted 0 times
...
Milly
10 months ago
Exactly, it's like a linguistic tug-of-war!
upvoted 0 times
...
Bettina
10 months ago
User2
upvoted 0 times
...
Jaclyn
10 months ago
Yeah, it swaps the strings, so it should print 'toHow'.
upvoted 0 times
...
Roosevelt
10 months ago
User1
upvoted 0 times
...
Hyun
10 months ago
I think option B is correct.
upvoted 0 times
...
...
Ronald
11 months ago
Wow, this is a tricky one. I'm going to have to go with option B and hope I'm right.
upvoted 0 times
...
Selene
11 months ago
I'm going with option B. Swapping the strings should give us 'toHow'.
upvoted 0 times
...
Jacquline
11 months ago
Hmm, I'm not sure about this one. Let me think it through... Ah, got it! Option B it is.
upvoted 0 times
...
Micaela
11 months ago
The swap function should swap the contents of the strings, so I'm going to go with option B.
upvoted 0 times
Martina
10 months ago
I see, so the correct answer is: Hoto
upvoted 0 times
...
Yuette
10 months ago
Yes, that's correct. The swap function swaps the contents of the strings.
upvoted 0 times
...
Yuette
10 months ago
I think it prints: toHow
upvoted 0 times
...
Peggie
10 months ago
Really? I thought it would be: toHow
upvoted 0 times
...
Billy
11 months ago
No, it actually prints: Hoto
upvoted 0 times
...
Karrie
11 months ago
I think it prints: toHow
upvoted 0 times
...
...

Save Cancel