I have problem with my template class. I specified default type of my template class like that:
template < class T = float >
class apple {
public:
T x;
apple(T x): x(x) {}
}
However, when I create the object like that:
apple obj(2);
The type turns into int unless I do that:
apple<float> obj(2);
How would I make it stay float?
Add this deduction guide to force all argument deductions to resolve to your default arguments:
template <class T>
apple(T) -> apple<>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With