Detecting Inherited Class Type
I've learned that I'm clueless when it comes to search engines because I can never find the information I want so here I am again asking for the help of fellow programmers. The title should say it all -- terrible, I know.
Anyway, I'm new to using STL containers and, having written them off for far too long I've finally realized the error of my ways and have come to appreciate and rely upon the power, simplicity and error prevention that the STL creates for programmers.
To that end, I've been pondering over this question for a bit.
Suppose I have a class, Entity. I create a vector, std::vector<Entity> myVector.
Now suppose that from Entity I've derived two additional Classes, Dog and Cat. I know that I can stuff those into my Entity Vector (I'm aware of slicing issues, suffice it to say that the derivities are purely logic differences in virtual functions).
Assuming that I've correctly initialized everything and populated the list randomly with Cat's and Dog's how, then, would I go about determining which type of derived Entity I'm using (Dog/Cat)? Is there a simple way of saying something like (warning, terrible psuedo code):
Or is this something I have to manage in a different way?
if(myVector == Dog)
else if(myVector == Cat)
barf with some uselessly vague message
Thanks for taking the time to read this! Looking forward to some guidance.