Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Point
- {
- private:
- int x, y, z;
- public:
- int podaj_x(){ return x; }
- int podaj_y(){ return y; }
- int podaj_z(){ return z; }
- void viewPoint();
- Point operator+(const Point&);
- Point operator-(const Point&);
- Point(){}
- Point(int x, int y, int z);
- ~Point();
- };
- Point::Point(int x, int y, int z) {
- this->x = x;
- this->y = y;
- this->z = z;
- }
- Point::~Point()
- {
- }
- void Point::viewPoint(){
- cout << "x: " << x << endl;
- cout << "y: " << y << endl;
- cout << "z: " << z << endl;
- }
- Point Point::operator + (const Point & prm){
- Point wynik;
- wynik.x = x + prm.x;
- wynik.z = z + prm.z;
- wynik.y = y + prm.y;
- return wynik;
- }
- Point Point:: operator-(const Point & parm){
- Point szmaty;
- szmaty.x = x - parm.x;
- szmaty.y = y - parm.y;
- szmaty.z = z - parm.z;
- return szmaty;
- }
- int main(){
- Point a(2, 5, 6);
- Point b(2, 6, 7);
- Point result, rezult;
- a.viewPoint();
- b.viewPoint();
- cout << endl << "a+b= " << endl;
- rezult = a + b;
- cout << endl;
- rezult.viewPoint();
- cout << endl << "ODEJMOWNIAE\n a-b=";
- result = a - b;
- result.viewPoint();
- }
- //#endif //!zad7.h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement