Skip to content

Instantly share code, notes, and snippets.

@patelmilanun
Last active April 23, 2017 18:20
Show Gist options
  • Save patelmilanun/9eea91a3e1f1a911973de55f61653eab to your computer and use it in GitHub Desktop.
Save patelmilanun/9eea91a3e1f1a911973de55f61653eab to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class coordinate
{
private:
int x,y,z;
public:
void set()
{
cout<<"Enter x:"<<endl;
cin>>x;
cout<<"Enter y:"<<endl;
cin>>y;
cout<<"Enter z:"<<endl;
cin>>z;
}
void print()
{
cout<<"x:"<<x<<endl;
cout<<"y:"<<y<<endl;
cout<<"z:"<<z<<endl;
}
void operator +=(coordinate c)
{
x+=c.x;
y+=c.y;
z+=c.z;
}
};
int main() {
// your code goes here
coordinate d,e;
d.set();
e.set();
d+=e;
d.print();
return 0;
}
=============output=================
Enter x:1
Enter y:2
Enter z:3
Enter x:1
Enter y:2
Enter z:4
x:2
y:4
z:7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment