//inside class
template<class T>
constdouble power(double, T);
//outside class
template<> constdouble math::power<signedint>(double a, signedint b)
{
bool return2 = false;
double value = a;
if(b < 0){
b = absolute(b);
return2 = true;
}
for(unsignedint i = 1; i<b; i++) a *= value;
if(return2) a = inverse(a);
return(a);
}
template<> constdouble math::power<double>(double a, double b) //error with this line
{ b *= 10000;
bool return2 = false;
double value = a;
if(b < 0){
b = absolute(b);
return2 = true;
}
for(unsignedint i = 1; i<b; i++) a *= value;
if(return2) a = inverse(a);
return(a);
}
I am getting an error with my second templated function
error: specialization of 'const double math::power(double, T) [with T = double]' after instantiation
Any help or suggestions would be greatly appreciated
-Giblit
ps: I haven't finished the second template function 100% so that it will take in fractions instead of doubles but that doesn't have an effect on my problem because I tried it with an output message and still got the error.
still new to c++ I had no idea you could overload functions like that thanks =] I was thinking you had to use templates to overload the functions. And maybe its my compiler though I think its mingw via qt because it did not compile for me I wish i read functions(2) lol http://www.cplusplus.com/doc/tutorial/functions2/