Advertisement
varungurnaney

MPSTME: Friend Function (easy)

Feb 6th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  
  4.  
  5. class square
  6. {
  7. int x;
  8. public:
  9. void set_value(int b)
  10. {x=b; }
  11. friend void find_square(square);
  12. };
  13.  
  14.  
  15. void find_square(square a)
  16. {
  17.   cout<<a.x*a.x<<endl ;
  18. }
  19. void main()
  20. {
  21. square s;
  22. clrscr();
  23. s.set_value(5);
  24. find_square(s);
  25. getch();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement