Created
February 13, 2018 08:04
-
-
Save nitishk72/2e396ee44f695a393ec8ca512e20d0a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
class A{ | |
int x; | |
public: | |
void getdata(){ | |
cout<<"\n Enter value of x:"<<endl; | |
cin>>x; | |
} | |
void showdata(){ | |
cout<<"\n Entered value is:"<<x<<endl; | |
} | |
}; | |
int main(){ | |
A obj; | |
A *ptr; | |
ptr = &obj; | |
ptr->getdata(); | |
ptr->showdata(); | |
(*ptr).getdata(); | |
(*ptr).showdata(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment