Declaration of a friend class is also similar. Only thing is a class definition is slightly different.
#include < iostream.h >
class CPP_Tutoriàl
{
in private_data:
friend class friendclass;
public:
CPP_Tutorial()
     {
private_data =5;
      }	};
class friendclass
{
public:
int subtractfrom(int x)
    {
CPP_Tutorial var2;
return var2.private_data - x;
    }
int main()
{
friendclass var3;
cout << “Added Result for this C++ tutorial:”<< var3.subtracttrom(2)<< ENDL;
}
<< GO BACK

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus






Footer1