#include <iostream>
using namespace std;
class B;
class A
{
int a = 10;
int b = 20;
public:
friend void A::display(B&a);
void display(B & c);
};
class B
{
int abc = 20;
public:
friend void A::display(B&a);
};
void A::display(B & c)
{
cout << c.abc;
}
int main()
{
B b;
A a;
a.display(b);
return 0;
}
it is giving the error on the 21th line that "abc" is inaccessible. Although it is a friend function and have access to B class' private data members
Aucun commentaire:
Enregistrer un commentaire