class DuzaLiczba {
public:
DuzaLiczba(string& input);
DuzaLiczba(const DuzaLiczba& orig);
bool operator==(const DuzaLiczba &other) const;
bool operator!=(const DuzaLiczba &other) const;
DuzaLiczba operator+(const DuzaLiczba& right) const;
DuzaLiczba operator-(const DuzaLiczba& right) const;
DuzaLiczba operator<(const DuzaLiczba& right) const;
DuzaLiczba operator>(const DuzaLiczba& right) const;
string& getData();
virtual ~DuzaLiczba();
private:
string& data;
};
И == оператор
bool DuzaLiczba::operator==(const DuzaLiczba &other) const {
string liczba1 = this->data;
string liczba2 = right.data;
char index1 = liczba1.length();
char index2 = liczba2.length();
short k;
short o;
short f = 0; //przeniesienie
string wynik;
int sizefi = 0;
char temp;
int i = 0;
//"gupie" to C# RUUUULEEEZ
// http://www.youtube.com/watch?v=bXoc9hOIj3M hahahaa "D
if (liczba1.length() == liczba2.length()) { //najpierw dlugosc szybciej niz pokolei
for (i = 0; i < index1; i++) {
if (liczba1[i] == liczba2[i]) { //sprawdza kazdy element jesli sie rozni to false
wynik =
"TRUE";
} else {
wynik = "FALSE";
}
}
} else {
wynik = "FALSE";
}
return DuzaLiczba(wynik);
}
И данные возврата
string& DuzaLiczba::getData() {
return data; //zwoloniony string
}
Все, что я хочу вернуть строку.dl1 = "123089127312890372109371203971293012903" dl2 = "12837129037812903812903" например.DuzaLiczba dl3 (dl1 + dl2) и cout it.
Код внутри класса отлично справляется с математикой.
Или создайте оператор перегрузки "<<". </p>