Illustrates invoking class members (data and function) via instance (objects) in C++
Program :-
#include<iostream.h>
class ABC
{
public: int i;
void display()
{
cout<<"Invoking member function through object";
}
};
void main()
{
ABC obj;
obj.i=4;
cout<<obj.i;
obj.display();
}
Output :-
4 Invking member functon through object
#include<iostream.h>
class ABC
{
public: int i;
void display()
{
cout<<"Invoking member function through object";
}
};
void main()
{
ABC obj;
obj.i=4;
cout<<obj.i;
obj.display();
}
Output :-
4 Invking member functon through object
Comments
Post a Comment