For learning purposes I'm creating big integer class in C++. There are 2 files:
big_int.h
#ifndef BIG_INT_H #define BIG_INT_H #include class big_int { public: big_int(void); big_int(char*); big_int(QString); ~big_int(); big_int operator+(big_int); big_int operator-(big_int); big_int operator*(big_int); big_int operator/(big_int); }; #endif // BIG_INT_H big_int.cpp
#include "big_int.h" big_int::big_int() { } big_int::big_int(QString str) { } big_int::~big_int() { } big_int operator+(big_int b) { return big_int(); } big_int operator-(big_int b) { return big_int(); } big_int operator*(big_int b) { return big_int(); } big_int operator/(big_int) { return big_int(); } Qt Creator returns: C:/Documents and Settings/Admin/My Documents/calculator_1_0/big_int.cpp:31: error: big_int operator/(big_int) must take exactly two arguments. But operator/ takes only 1 parameter. What`s wrong?
operator+=first, and defineoperator+in terms of that (create a copy of one addend and add the other to it). You are going to want a copy constructor (big_int::big_int(const &big_int)). Less importantly, you should normally accept and return const references (const big_int & big_int::operator+=(const &big_int), although that's more a performance thing, so you don't need to worry about that yet.