L
Lawrence Spector
How does one call a templated constructor inside of a class when
instantiating an object? I made up a quick sample to demonstrate.
#include <iostream>
class TestClass
{
public:
template <class T>
TestClass()
{
std::cout << "Called with type " << typeid(T).name() << std::endl;
}
};
int main()
{
TestClass testClass; // Error: How do I call the constructor and tell
it that I want to use an int for the template type?
std::cin.get();
return 0;
}
If it was done implicitly, where T was used in the parameter list of
the constructor, then it would be easy, but I actually have a case
where I need to be explicit.
Thanks in advance,
Lawrence
instantiating an object? I made up a quick sample to demonstrate.
#include <iostream>
class TestClass
{
public:
template <class T>
TestClass()
{
std::cout << "Called with type " << typeid(T).name() << std::endl;
}
};
int main()
{
TestClass testClass; // Error: How do I call the constructor and tell
it that I want to use an int for the template type?
std::cin.get();
return 0;
}
If it was done implicitly, where T was used in the parameter list of
the constructor, then it would be easy, but I actually have a case
where I need to be explicit.
Thanks in advance,
Lawrence