#include < iostream.h >
// Declaration of the function to be made as friend for the C++ 
int AddToFriend(int x);
class CPP_Tutorial
{
int private_data; 
friend int AddToFriend(int x); 
public:
CPP_Tutorial()
{
private_data =5;
}
};
int AddToFriend(int x)
{
CPP_Tutorial var1;
return var1.private_data + x;}

int main() {
cout << “Added Result for this C++ tutorial: “<< AddToFriend(4) << endl;
}
<< GO BACK

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus




Footer1