For an array if I want an array of integers it's:
int anArray[];
For an array of strings it is:
string anArray[];
I have a binary search tree template that allows t开发者_开发问答he type to be chosen using a typedef:
typedef desiredType TreeItemType; // desired type of tree items i.e. string, int, etc.
How can I get two different trees of two different types? Right now the only way I see possible is to write all the supporting code twice with different file names and setting the typedef's. There has to be a way to set the typedef desiredType in a method or something. Any ideas?
why not turn it into a templated class, seeing as your using C++? this allows any number of permutations of types, and remove any problems that might occur with a typedef'd type(aliased type).
精彩评论