PROGRAM TO SHOW CONCEPT OF FRIEND CLASS

/*PROGRAM TO SHOW CONCEPT OF FRIEND CLASS*/

#include<conio.h>

#include<iostream.h>

class tempA

{

int a;

public:

void get_a()

{

cout<<“Enter a: “;

cin>>a;

}

friend class tempB;

};

class tempB

{

public:

void display(tempA t1)

{

cout<<“Value of a is: “<<t1.a;

}

};

void main()

{

tempA t1;

tempB t2;

clrscr();

t1.get_a();

cout<<“Function of friend class is called”<<endl;

t2.display(t1);

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *