Computer Science, asked by sagarpgowda11p6hjtx, 1 year ago

Describe the mechanism of accessing data member and member function inside the member function of same class

Answers

Answered by shivashankaran
0
the mechanism of accessing data members and member functions in the following cases is done by 1.Using object and dot membership operator. 
2.accessing a local variable of a function. Example for how to access data members and member functions inside a member function of another class. #include<iostream.h>  class a 
{      public:             int x;       void display()        {            cout<<"sample \n";             x=111;        } };  class b {      public:       void display()       {           a s; cout<<" Member function \n"; s.display();           cout<<" x = "<<example<<"\n";       } };  void main() {          b  b1; // b1 is a object of class b.           b1.display(); }

Similar questions