Created
April 17, 2016 20:53
-
-
Save Mahmoud-Sagharjoughi/ad5a961d003749841471bf02376ab0f4 to your computer and use it in GitHub Desktop.
Vector3D
This file contains 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 Vector3D | |
{ | |
public: | |
Vector3D(int x,int y,int z) | |
{ | |
this->x = x; | |
this->y = y; | |
this->z = z; | |
} | |
Vector3D& operator + (Vector3D& c) | |
{ | |
this->x += c.x; | |
this->y += c.y; | |
this->z += c.z; | |
return *this; | |
} | |
void Print(); | |
private: | |
int x; | |
int y; | |
int z; | |
}; | |
void Vector3D::Print() | |
{ | |
cout << x << "," << y << "," << z << endl; | |
} | |
int main() | |
{ | |
int x1; | |
int y1; | |
int z1; | |
int x2; | |
int y2; | |
int z2; | |
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; | |
Vector3D A_1(x1,y1,z1); | |
Vector3D A_2(x2,y2,z2); | |
Vector3D ASum = A_1 + A_2; | |
ASum.Print(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment