Which code, inserted at line 15, generates the output "5 Bob"?

Which code, inserted at line 15, generates the output "5 Bob"?

#include <iostream>

#include <string>

using namespace std;

class B;

class A {

int age;

public:

A () { age=5; };

friend void Print(A &ob, B &so);

};

class B {

string name;

public:

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

//insert code here

};

void Print(A &ob, B &so) {

cout<<ob.age << " " << so.name;

}

int main () {

A a;

B b;

Print(a,b);

return 0;

}
A . friend void Print(A ob, B so);
B . friend void Print(A &ob, B &so);
C . friend void Print(A *ob, B *so);
D . None of these

Answer: B

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments