Czesc, nie rozumiem jak dodac dwa vectora bo nie wiem jak do nich odwołać sie "friend Vector operator+(const Vector& , const Vector&)"
#include <iostream>
class Vector {
double x, y, z;
public:
Vector(){
x = 0;
y = 0;
z = 0;
};
Vector(double x, double y, double z) {
this->x = x;
this->y = y;
this->z = z;
};
Vector operator-() const {
const_cast<Vector*>(this)->x *= -1;
const_cast<Vector*>(this)->y *= -1;
const_cast<Vector*>(this)->z *= -1;
return Vector();
};
Vector operator*(double a) const {
const_cast<Vector*>(this)->x *= a;
const_cast<Vector*>(this)->y *= a;
const_cast<Vector*>(this)->z *= a;
return new Vector();
};
friend Vector operator+(const Vector& , const Vector& ) {
};
friend Vector operator-(const Vector& , const Vector& ) {
};
friend double operator*(const Vector& , const Vector& ) {
};
friend Vector operator*(double, const Vector&) {
};
friend std::ostream& operator<<(std::ostream&, const Vector&) {
};
};
// ...
int main() {
Vector w1(1,1,1), w2(2,2,2), w3(1,2,1);
Vector v = -(w1+w2-w3);
Vector w = 2*v+w1*2;
std::cout << v << " " << w
<< " " << v*w << std::endl;
}