Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- class Vektor3d{
- double x,y,z;
- public:
- Vektor3d(){x=0; y=0; z=0;}
- Vektor3d(double a, double b, double c){x=a; y=b; z=c;}
- void PostaviX (double x){Vektor3d::x=x;}
- void PostaviY(double y){Vektor3d::y=y;}
- void PostaviZ(double z){Vektor3d::z=z;}
- void Ocitaj(double &x, double &y, double &z)
- {x=Vektor3d::x; y=Vektor3d::y; z=Vektor3d::z;}
- friend std::ostream& operator<<(std::ostream &tok, const Vektor3d &v)
- { return tok<<"("<<v.x<<","<<v.y<<","<<v.z<<")"; }
- double DajX() const{return x;}
- double DajY() const{return y;}
- double DajZ() const{return z;}
- friend Vektor3d operator+(const Vektor3d &a, const Vektor3d &b)
- {return {a.x+b.x, a.y+b.y, a.z+b.z};}
- Vektor3d &operator+=(const Vektor3d &v)
- {this->x+=v.x; this->y+=v.y; this->z+=v.z; return *this;}
- Vektor3d &operator*=(const Vektor3d &v)
- {this->x*=v.x; this->y*=v.y; this->z*=v.z; return *this;}
- };
- int main(){
- Vektor3d a(1,2,3),b(10,10,10),c;
- c=a+b; std::cout<<c;
- Vektor3d v(a);
- v*=a; std::cout<<v;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement