Social Sciences, asked by rawatdeepaindor3283, 1 year ago

Describe the mechanism of accessing data members and member functions in the following cases: (i) inside the main program

Answers

Answered by aqibkincsem
40
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