Is it possible to access the private or public variables of a class within another class using friend class.If so, how?
I am a beginner at c++ programming, so any help would be welcome
class person
{
private:
int age;
int height;
friendclass consultant;
};
class consultant
{
private:
Person aPerson;
cout<<"how old are you";
cout<<aPerson.age;
//consultant has permision to access private data of person since they are friends
cout<<"how told are you?";
cout<<aPerson.height;
};