Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ templated class instantiation

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


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.

Name: Anonymous 2011-02-21 21:04

>>1
Fuck you.

Name: Anonymous 2011-02-21 21:06

>>2
That was very enlightening.

Name: Anonymous 2011-02-21 21:31

>>1

fuck you faggot

Name: Anonymous 2011-02-21 21:50

>>2,4 are too busy to suck on cocks to post a useful reply.

Name: Anonymous 2011-02-21 22:37

>>1
I don't know if you're trolling or you really are that dense.

Templates are compile-time mechanisms. You can't instantiate them at run time.

Name: Anonymous 2011-02-22 4:02

>>6
YHBT

Don't change these.
Name: Email:
Entire Thread Thread List