Problem : w przeładowaniu operatora + nie rozpoznaje mi zmiennej x, y :)
#include <iostream>
#include <string>
using namespace std;
//obliczanie wektorow za pomoca klasy...
class wektor
{
double x;
double y;
public:
wektor(double pierwsza, double druga);
wektor operator+(wektor v);
wektor operator*(wektor v);
void wypisz();
};
wektor::wektor(double pierwsza, double druga):x(pierwsza),y(druga)
{
cout<<"konstruktor..."<<endl;
}
wektor::wektor operator+(wektor v)
{
x = x + v.x ;
y = y + v.y;
cout<<"wspolrzedne wektora "<x<<y<<endl ;
}
wektor::wektor operator*(wektor v)
{
x = x * v.x ;
y = y * v.y;
cout<<"wspolrzedne wektora "<x<<y<<endl ;
}
void wektor::wypisz()
{
cout<<"Dane wektora: "<<endl;
cout<<"("<<x<<","<<y<<")"<<endl;
}
int main()
{
wektor A(5,4) ;
wektor B(5,1) ;
A.wypisz();
}
z góry thx za znalezienie błędu :)