R
Ralf Goertz
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 T> class foo {
T x;
public:
void do_something_depending_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<int> bar;
bar.do_something_depending_on_type_of_T();
return 0;
}
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 T> class foo {
T x;
public:
void do_something_depending_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<int> bar;
bar.do_something_depending_on_type_of_T();
return 0;
}