Hi,
I want to do able to declare an object bar of a templated class foo
where the actual template type of foo is only know at runtime:
-----
#include <string>
template <class Tclass foo {
T x;
public:
void do_something_de pending_on_type _of_T(){
...
};
}
int main(int argc, char *argv[]) {
if (argc==1) //default type string should be used
foo<std::string bar;
else //use class int
foo<intbar;
bar.do_somethin g_depending_on_ type_of_T();
return 0;
}
-----
I know it doesn't work like this but is it possible at all?
Ralf
I want to do able to declare an object bar of a templated class foo
where the actual template type of foo is only know at runtime:
-----
#include <string>
template <class Tclass foo {
T x;
public:
void do_something_de pending_on_type _of_T(){
...
};
}
int main(int argc, char *argv[]) {
if (argc==1) //default type string should be used
foo<std::string bar;
else //use class int
foo<intbar;
bar.do_somethin g_depending_on_ type_of_T();
return 0;
}
-----
I know it doesn't work like this but is it possible at all?
Ralf
Comment