przeladowanie operatora i brak dostepnosci do zmiennych

0

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 :)

0

Pomieszały się ci trochę definicje metod ;P

#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();
}
0

dzięki serdeczne za pomoc ;)

1 użytkowników online, w tym zalogowanych: 0, gości: 1