Name: Anonymous 2011-02-21 21:00
I'm currently doing this assignment for C++ involving templates and I was wondering if it is possibly to initialize a template class without knowledge of what typename it will make.
We're suppose to make a basic template List class.
When the program executes, one of the parameters passed to it through argv is the type it should take. so
mylist string
would make a list class of type string and
mylist double
would make a list class of type double.
So is it at all possible to do something like
Right now I've got a main function that makes lists of several data types and as a result is littered with switch statements. It looks like a goddamn mess so that's why I came here.
We're suppose to make a basic template List class.
When the program executes, one of the parameters passed to it through argv is the type it should take. so
mylist string
would make a list class of type string and
mylist double
would make a list class of type double.
So is it at all possible to do something like
int main (int argc, char **argv)
{
List *someList;
someList = createNewList(argv[1]);
//rest of code
}Right now I've got a main function that makes lists of several data types and as a result is littered with switch statements. It looks like a goddamn mess so that's why I came here.