hi
i have many object and i overloaded operator + in my class
i want let user to choose objects.
so i get the name of subjects from user
now how can run function +
(for example user enter A and B how can i run (A+B;) )
Printable View
hi
i have many object and i overloaded operator + in my class
i want let user to choose objects.
so i get the name of subjects from user
now how can run function +
(for example user enter A and B how can i run (A+B;) )
If you want to refer to the variables by name based on user input, perhaps you could use a std::map.
Maybe, but why do you reject the approach that I have suggested?Quote:
Originally Posted by aminpost
What made you come to the conclusion that you should use an array of objects that know their own name (or rather, are assigned names by which they can be referenced)? It is certainly possible, but you would need to keep the array in sorted order by "object name" in order to use binary search. A std::map or std::tr1::unordered_map is likely to be easier.Quote:
Originally Posted by aminpost