Originally I had created the GameObject class as an interface for all game objects. So that I can implement Polymorphism for various general tasks related to game objects.
Ok, this means you expected to have a lot of common properties in all objects, right?
Personally, I have some reservations, but I also see firm believers in this approach here, so let's assume here your ideas were correct.
Now that you created the game, how many methods do you have as truly common (ie fully fitting in your goal) methods? How many do not? Are there positive or negative exceptions there? Was your idea worth it, in hindsight?
Assuming you are talking about std::map and assuming you are talking about its efficiency.
Then I think integers would have worked better. And hence I should have created a enum of object names, right?
Or is this not what you are asking?
My question was intended much more generally. You picked GameObject because you expected it to help you in solving your problem (you said "...created the GameObject class as an interface for all game objects. So that I can implement Polymorphism for various general tasks..."). Now, looking back, is it actually doing that? Is it doing that well? (probably not, since you asked about it). So what is it not doing that you expected beforehand? Why? (can you think of reasons to explain why it didn't work out as you intended).
One: The one which I mentioned above about efficiency.
I would say, the first goal should be to have good global game structures. That may also be the second and third goals. If your data structures are well designed, efficiency mostly comes by itself.
In the details you can still gain a lot, but the impact is a lot less than a well designed overall structure.
For fixing problem one mentioned above: Using integers for increase in performance
If you can switch to integers, why do you need a map? I mean, a vector or an array would work too, right? That also holds for using enums, of course.
maybe the eliminate the need of downcasting completely!
I find this an interesting thought.
If you look at what you did from a distance, I think you'd see the following:
You wrapped all objects in a black uniform box. They are nicely stackable, and they fit exactly in the new closet that you bought. It all looks so tidy.
Now after a while, you find out that at times, you want to look inside the box, to see what it contains. Apparently, everything in the same box isn't ideal.
So maybe you shouldn't have coloured all boxes black? Maybe use different colours for different kinds of things? (my reservations about universal objects surfaces here!!).
As a thought experiment, what would happen if you delete the GameObject class? Would having several collections of different object types help?
At the end, I seem quite motivated by my dislike about universal classes, so you may want to take my comments and questions with that in mind.