Skip to content

Instantly share code, notes, and snippets.

@nitishk72
Created February 13, 2018 08:19
Show Gist options
  • Save nitishk72/3230ccc93ef50edfd8ce6de089a22a92 to your computer and use it in GitHub Desktop.
Save nitishk72/3230ccc93ef50edfd8ce6de089a22a92 to your computer and use it in GitHub Desktop.
Sum of two number using pointer Object
#include<iostream>
using namespace std;
class A{
int x,y,z;
public:
void add(){
cout<<"Enter value of x "<<endl;
cin>>x;
cout<<"Enter value of y "<<endl;
cin>>y;
z = x + y;
cout<<"Sum = "<<z<<endl;
}
};
int main(){
A obj;
A *ptr;
ptr = &obj;
ptr->add();
(*ptr).add();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment