Problem polega na tym, jest niezgodność z zaprzyjaźnioną funkcją operatora*. Funkcja posiada 2 argumenty i definicję. Sprawdzałem wiele artykułów i nie wiem gdzie leży błąd.
plik nagłówkowy:
#ifndef STONEWT_H_
#define STONEWT_H_
#include <iostream> // dla obiektu std::ostream
class Stonewt
{
private:
enum {Lbs_per_stn = 14}; //liczba funtów na kamienie
int stone; //masa w całych kamieniach
double pds_left; //reszta w funtach
double pounds; //masa w funtach
public:
//konstruktory
Stonewt(); //kontruktor domyśny
Stonewt(double lbs); //konstruktor dla funtów
Stonewt(int stn, double lbs); //konstruktor dla kamieni i funtów
//przeciążenia
Stonewt operator+(const Stonewt & value) const; //przeciążenie operatora+ dla...
Stonewt operator-(const Stonewt & value) const; //przeciążenie operatora- dla...
friend Stonewt operator*(double d_value, const Stonewt & value); //przeciążenie operatora* dla...
friend std::ostream & operator<<(std::ostream & os, const Stonewt & text);
};
#endif
deklaracje:
#include "stonewt.h" // zawiera <iostream>
Stonewt::Stonewt() { stone = pounds = pds_left = 0; }
Stonewt::Stonewt(double lbs)
{
stone = int (lbs) / Lbs_per_stn; //dzielenie całkowite
pds_left = int (lbs) % Lbs_per_stn + lbs - int (lbs);
pounds = lbs;
}
Stonewt::Stonewt(int stn, double lbs)
{
stone = stn;
pds_left = lbs;
pounds = stn * Lbs_per_stn + lbs;
}
Stonewt Stonewt::operator+(const Stonewt & value) const { return Stonewt(stone + value.stone, pounds + value.pounds); }
Stonewt Stonewt::operator-(const Stonewt & value) const { return Stonewt(stone - value.stone, pounds - value.pounds); }
Stonewt operator*(double d_value, const Stonewt & value) { return value * d_value; }
std::ostream & operator<<(std::ostream & os, const Stonewt & text)
{
os << "Masa w kamieniach: " << text.stone << " kamieni, " << text.pds_left << " funtów\n" << "Masa w funtach: " << text.pounds << " funtów\n";
return os;
}
Proszę o podpowiedź co mogło pójść tutaj nie tak.