Friend Function | CPP Object Oriented Programming

  c++

Email

#include<iostream>

using namespace std;

class Anil{

string name;
int age;

public :

Anil(string iname, int iage)
{
name = iname;
age = iage;

}

void disp()
{

cout << name << age;
}
friend void displya(Anil man);

};

void displya(Anil man)
{

cout << man.name << man.age;

}

int main()
{

Anil naik(“this mainof the class “,00);

displya(naik);
return 0;

}

Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of