Class Program 5

Write a program to call member functions of class in the main function using pointer to object and pointer to member function.




#include<iostream>

using namespace std;
class abc
{
             int a;
 public:
            void seta()
            {
              a=5;
            }
            void printa()
            {
              cout<<a<<endl;
            }
           
};

void main()
{
            abc o1,*p;
            p=&o1;
            p->seta();
            p->printa();
           
}