I am trying to make the constructor to set default values for template types as following:
With this struct template
template<class Type1, class Type2>
struct Pair
This is my constructor:
Pair(const Type1& t1 = Type1(), const Type2& t2 = Type2()) :
first(t1), second(t2)
{}
I use calls to the default constructor of each type. Everything goes with if I call the constructor with params:
Pair<float, double> pair_fd(1, 1);
But when I make the call without params the program gives linker errors.
Is possible to achieve what i am trying? If so, what am I missunderstanding?
Thank you all.
Solved.
I was trying to create the variable like
Pair<float, double> pair_fd();
Instead of
Pair<float, double> pair_fd;
Thanks @chris