Skip to content

Instantly share code, notes, and snippets.

@nitishk72
Created February 13, 2018 08:04
Show Gist options
  • Save nitishk72/2e396ee44f695a393ec8ca512e20d0a0 to your computer and use it in GitHub Desktop.
Save nitishk72/2e396ee44f695a393ec8ca512e20d0a0 to your computer and use it in GitHub Desktop.
#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