Make your pointer constructor parameter to T*& qValue
.
TemplateOverLoading(std::string& qName, T*& qValue )
: mName(qName),
mValue( qValue)
{
std::cout << "Pointer "<< *mValue <<"\n";
}
By making it a reference to a pointer, array-to-pointer decay is prevented and the array constructor is chosen.
Also, I don't see how your code compiles, I see many errors:
Your template constructor has a parameter class T
, this conflicts with the class T
of the class template:
template<class T, int N>
TemplateOverLoading(std::string& qName, T (&t)[N])
This needs to be changed to something else than class T
, for example class U
:
template<class U, int N>
TemplateOverLoading(std::string& qName, U (&t)[N])
Your constructors also take a non-const lvalue reference, non const reference cannot bind to temporaries, which you are passing in the constructor call, i.e. std::string("mIntArray")
. You need to change it to const std::string&
or take it by value. Also your member std::string& mName;
is a reference, you should remove the &
there.