This is a sample program On using Friend Classes. Using Friend class, here we try to find the mean of two numbers. #include <iostream.h> #include <conio.h> class num { int a,b; public: void read() { cout<<" Enter Two Numbers: "; cin>>a>>b; } friend void mean(num x) { int k; k=(x.a+x.b)/2; cout<<" Arithmetic Mean: "<<k; } }; void main() { clrscr(); num n; n.read(); mean (n); getch(); } OUTPUT: Enter Two Numbers: 18 ...
All HR and Technical interview questions with answers for freshers and experienced professional. It helps job seekers who are about to attend interviews.