Friend class

Write a program to demonstrate the use of a friend class.

#include<iostream>
using namespace std;
class A
{
	private:
		int x,y;
	public:
		friend void setdata(A&);
		friend void print(A&);
};
void setdata(A& t)
{
	cout << "Enter values for x and y = ";
	cin >> t.x >> t.y;
}
void print(A& t)
{
	cout << "x = " << t.x << " y = " << t.y << endl;
}
int main()
{
	A obj;
	setdata(obj);
	print(obj);
	return 0;
}

Output

Enter values for x and y = 55 65
x = 55 y = 65