Предположим, объявление MyClass:
Код: Выделить всё
template class MyClassT { ... };
Код: Выделить всё
template
MyClassT operator*(const MyClassT& t, const MyClassT& u)
{
//...
}
template ,bool> = true >
MyClassT operator*(const MyClassT& t, const U& u)
{
//...
}
template ,bool> = true >
MyClassT operator*(const T& t, const MyClassT& u)
{
//...
}
Код: Выделить всё
MyClassT a;
double b;
MyClassT c = a * b;
Подробнее здесь: https://stackoverflow.com/questions/786 ... verloading
Мобильная версия