Monday 26 April 2021

Friend Function in C++ Qus - 2

  class A

{

  private:

  int a;

  void display()

  {

      a=10;

      cout<<"Display"<<endl;

  }

  friend void show();

};


void show()

{

    A ob;

    cout<<ob.a<<endl;

    ob.display();

     cout<<ob.a<<endl;

}

int main() {

   show();

}



Output


Garbage Value

Display

10

No comments:

Post a Comment