#include<iostream.h> #include<conio.h> /*************************************************************************///------------------------- CLass Declarations ------------------------///*************************************************************************/class two; /*************************************************************************///------------------------------ one ----------------------------------///*************************************************************************/class one { private: int data_1; public: one() { data_1=100; } friend int access_both(one,two); }; /*************************************************************************///------------------------------ two ----------------------------------///*************************************************************************/class two { private: int data_2; public: two() { data_2=100; } friend int access_both(one,two); }; /*************************************************************************///------------------------- access_boyh(one,two) ----------------------///*************************************************************************/int access_both(one a,two b) { return (a.data_1+b.data_2); } main() { clrscr(); one a; two b; cout<<"\n Data returned by the function access_both(one,two) = "; cout<<access_both(a,b); getch(); return 0; }
No comments:
Post a Comment