tampurus

6.1 Friend Function (more... example)

Nov 24th, 2021 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class suresh{
  4.     int a;
  5.     public:
  6.     void read(){
  7.         cout<<"Enter value of a ";
  8.         cin>>a;
  9.     }
  10.     friend void display(suresh s1);
  11. };
  12. void display(suresh s1){
  13.     cout<<s1.a;
  14. }
  15. int main()
  16. {
  17.     suresh c1;
  18.     c1.read();
  19.     display(c1);
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment