C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 66 Topic 7 Discussion

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 66 Topic 7 Discussion

CPA-21-02 Exam Topic 7 Question 66 Discussion:
Question #: 66
Topic #: 7

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

#include

#include

using namespace std;

class B;

class A {

int age;

public:

A () { age=5; };

friend class B;

};

class B {

string name;

public:

B () { name="Bob"; };

void Print(A ob) {

cout << name << ob.age;

}

};

int main () {

A a;

B b;

b.Print(a);

return 0;

}


A.

It prints: Bob5


B.

It prints: Bob


C.

It prints: 5


D.

None of these


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.