G
Gunnar G
Hello.
I'm trying to write a class for integers with a very large number of digits
and it seemed to work until I tried to add three numbers.
d=a+b+c; works fine (hasn't checked the result yet)
but
d=a+(b+c); does not work. ( I have added the parentesis to make sure b+c is
calculated first).
The error I get is:
g++ Bigint.cpp main.cpp && ./a.out
main.cpp: In function `int main(int, char**)':
main.cpp:14: error: no match for 'operator+' in 'c +
Bigint:
perator+(Bigint&)((&d))'
Bigint.h:17: error: candidates are: Bigint Bigint:
perator+(Bigint&)
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/stl_bvector.h:202:
error:
std::_Bit_iterator std:
perator+(int, const
std::_Bit_iterator&)
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/stl_bvector.h:261:
error:
std::_Bit_const_iterator std:
perator+(int, const
std::_Bit_const_iterator&)
I assume that there is something very basic thing that I have missed. Here
is the Bigint.h file:
class Bigint{
protected:
vector<int> coef;
bool negative;
public:
void trim();
Bigint(); // sets the integer to 0
Bigint(int x); // sets the integer to x
Bigint operator+(Bigint& x);
friend ostream& operator<<(ostream& out,const Bigint& myint);
};
The Bigint.cpp file is somewhat long, so I dont send it.
Can anyone help me to figure out what is wrong?
I'm trying to write a class for integers with a very large number of digits
and it seemed to work until I tried to add three numbers.
d=a+b+c; works fine (hasn't checked the result yet)
but
d=a+(b+c); does not work. ( I have added the parentesis to make sure b+c is
calculated first).
The error I get is:
g++ Bigint.cpp main.cpp && ./a.out
main.cpp: In function `int main(int, char**)':
main.cpp:14: error: no match for 'operator+' in 'c +
Bigint:
Bigint.h:17: error: candidates are: Bigint Bigint:
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/stl_bvector.h:202:
error:
std::_Bit_iterator std:
std::_Bit_iterator&)
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3/bits/stl_bvector.h:261:
error:
std::_Bit_const_iterator std:
std::_Bit_const_iterator&)
I assume that there is something very basic thing that I have missed. Here
is the Bigint.h file:
class Bigint{
protected:
vector<int> coef;
bool negative;
public:
void trim();
Bigint(); // sets the integer to 0
Bigint(int x); // sets the integer to x
Bigint operator+(Bigint& x);
friend ostream& operator<<(ostream& out,const Bigint& myint);
};
The Bigint.cpp file is somewhat long, so I dont send it.
Can anyone help me to figure out what is wrong?