Hello, i have a class that is a template, I have to declare it in my main but i want the user to choose what type of data they will use in the class, I cant just declare myclass my, i have to use myclass<int> my, how can I change so user can select the proper datatype to use in the class.
its for a hashtables that could contain char,string,int,double,float.
you can instantiate the template with a type modeling all of them, dynamically. You can use boost variant for a ready-made solution ( if I recall correctly, it automatically inherits the comparison operators of its costituent types, so it would work immediately with associative containers; that said, adding hash support should be easy anyway ); otherwise, you can easily write your own "dynamic" type implementation ...
of course, as mentioned by laserlight, note that all this would defeat the benefit of compile time instantiation.
Hi, Sorry i was a big vague, no i didnt want them in a single container, i just wanted to save having many hashtables lying around, but actually its worked out better making tables of ints, char and the rest and having overloads just place them in the right container. Thanks to the original reply i know a bit more about using templates in my hashmaps.