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 )
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.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Maybe, but why do you reject the approach that I have suggested?Originally Posted by aminpost
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.Originally Posted by aminpost
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)