C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 51 Topic 6 Discussion

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 51 Topic 6 Discussion

CPA-21-02 Exam Topic 6 Question 51 Discussion:
Question #: 51
Topic #: 6

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

#include

using namespace std;

class A {

public :

void print() {

cout << "A ";

}

};

class B {

public :

void print() {

cout << "B ";

}

};

int main() {

B sc[2];

A *bc = (A*)sc;

for (int i=0; i<2;i++)

(bc++)->print();

return 0;

}


A.

It prints: A A


B.

It prints: B B


C.

It prints: A B


D.

It prints: B A


Get Premium CPA-21-02 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.