I have template method and i would like the template method use a specific method from a class to do the operation. Is it possible ?
template<typename T>
int minus(T t1,T t2){
return t1-t2;
}
And in my apple object class i have a method called getPrice()
How can i combine both.
Is this correct ?
template<typename T>
int minus(T t1,T t2){
return t1.getPrice()-t2.getPrice();
}
For this you probably want an ordinary function for your type: