I have a class called Time. There are only two private members: int hours and int minutes. The public access specifier only contains functions like adding, subtracting etc.
But there's a particular function which doesn't behave the way I want. It's declared public in the class.
This way it compiles:
Time Time::operator*(const int &mult)
{
   minutes = minutes*mult;
   hours = hours*mult + minutes/60;
   minutes %= 60;
   return *this;
}
But what if the argument isn't na int, but a float, or double? I suppose using templates is the best option, rather than overloading the function:
template <class T> Time Time::operator*(const T &mult)
{
   minutes = int(minutes*mult);
   hours = int(hours*mult) + minutes/60;
   minutes %= 60;
   return *this;
}
However, writing it this way gives a compile error:
error LNK2019: unresolved external symbol "public: class Time __thiscall Time::operator*<int>(int const &) " (??$?DH@Time@@QBE?AV0@ABH@Z) referenced in function _main
It means that I can't use operator overloading with templates or what?
Thank you
Robert
 
     
    