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 6 Question 71 Discussion

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

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

#include

#include

using namespace std;

class Second;

class Base {

int age;

public:

Base () { age=5; };

friend void set(Base &ob, Second &so);

void Print() { cout << age;}

};

class Second {

string name;

public:

friend void set(Base &ob, Second &so);

void Print() { cout << name;}

};

void set(Base &ob, Second &so) {

ob.age = 0; so.name = "Bill";

}

int main () {

Base a;

Second b;

set(a,b);

a.Print();

b.Print();

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Currently there are no comments in this discussion, be the first to comment!


Save Cancel