This is probably a really easy fix but I just cant seem to figure it out..
I am trying to make it so say for example I have a class that will store a large number. Then I have derived classes for base units, kilo units , mega....ect..
Then add those derived classes to the large number class but it doesn't seem to be working.
BigInt( void );
BigInt& operator+= ( const T& ); //compiles but I don't think is correct.
void error( constshort& ); //assert for value in wrong unit.
class Base : public BigInt
Base( void );
Base( constshort& );
template <class T>
BigInt& BigInt::operator+= ( const T &value ) //This compiles but isn't correct I think
//^^^ This function worked good when I had const Base &value as a parameter
//I am trying to template since all the derived classes are using the same
//thing to add to the base class.
Base ba( 400 ); //setting value to 400
bi.value = "600"; //setting value to 600
bi += ba;/**This line gets the error**/
Error -> undefined reference to `BigInt& BigInt::operator+=<Base>(Base const&)'
Any help would be greatly appreciated.
**Added a little bit more info**
if I do this it works but that would be a really big pain to overload the operator+= like 20 times. I am having a hard time trying to template the parameter of operator+= any help/suggestions would be great :)
I still would like to know how to template a function with different objects although I changed my code. I can run my program to do euler project 20 in .2 seconds and my class lets me go way beyond It did 1e10e3 * 1e10e3 in about 12 seconds so I'm not sure if that is good or bad =p and the number have to be less than 1073741820 9's but I guess I could make it go to another string after that but too lazy.
Cool thanks works when I put the definition in the header. I didn't know you had to do that with templates I just figured it was like normal parameters. Also thanks for the info on translation I'll have to read up on that some more later.