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-21-02 Topic 1 Question 7 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 7
Topic #: 1
[All CPA-21-02 Questions]

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

#include

#include

using namespace std;

class A {

public:

A() { cout << "A0 ";}

A(string s) { cout << "A1";}

};

class B : public A {

public:

B() { cout << "B0 ";}

B(string s) { cout << "B1 ";}

};

class C : private B {

public:

C() { cout << "C0 ";}

C(string s) { cout << "C1 ";}

};

int main () {

B b1;

C c1;

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Xochitl
4 days ago
I disagree, I believe the answer is B because the code creates objects of class B and class C with string parameters.
upvoted 0 times
...
Huey
6 days ago
I think the answer is A because the code creates an object of class B without any parameters.
upvoted 0 times
...
Cathrine
8 days ago
Hmm, I see your point. But I still think option A makes more sense based on the code logic.
upvoted 0 times
...
Kenneth
11 days ago
I disagree, I believe the correct answer is C. It prints: A no parametersB string parameter.
upvoted 0 times
...
Cathrine
12 days ago
I think the answer is A. It prints: A no parametersA no parametersB string parameter.
upvoted 0 times
...

Save Cancel