Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - 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
1 years ago
Haha, this code is like a linguistic tug-of-war! I think option B is the winner here.
upvoted 0 times
Venita
12 months ago
Yeah, the swap function switches the positions of the strings in the array.
upvoted 0 times
...
Whitley
1 years ago
I agree, option B is the correct answer.
upvoted 0 times
...
Milly
1 years ago
Exactly, it's like a linguistic tug-of-war!
upvoted 0 times
...
Bettina
1 years ago
User2
upvoted 0 times
...
Jaclyn
1 years ago
Yeah, it swaps the strings, so it should print 'toHow'.
upvoted 0 times
...
Roosevelt
1 years ago
User1
upvoted 0 times
...
Hyun
1 years ago
I think option B is correct.
upvoted 0 times
...
...
Ronald
1 years 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
1 years ago
I'm going with option B. Swapping the strings should give us 'toHow'.
upvoted 0 times
...
Jacquline
1 years 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
1 years ago
The swap function should swap the contents of the strings, so I'm going to go with option B.
upvoted 0 times
Martina
1 years ago
I see, so the correct answer is: Hoto
upvoted 0 times
...
Yuette
1 years ago
Yes, that's correct. The swap function swaps the contents of the strings.
upvoted 0 times
...
Yuette
1 years ago
I think it prints: toHow
upvoted 0 times
...
Peggie
1 years ago
Really? I thought it would be: toHow
upvoted 0 times
...
Billy
1 years ago
No, it actually prints: Hoto
upvoted 0 times
...
Karrie
1 years ago
I think it prints: toHow
upvoted 0 times
...
...

Save Cancel