Okay, I'm using void pointers because I need an vector of attributes that can be of many types float, int, double, Vector2(custom class), Matrix ... etc. It seems to me that void pointers are the best way to do this. The reason I need to cast before deleting is that one simply cannot delete a void pointer. Please tell me if there are any glaring weakness in this design. Thanks!
You say you need a vector of attributes that can be of different types. But unless you know the type of it you cannot utilise it appropriately. At some point you have to know the type, so you shouldn't need to cast.
1 2 3 4 5 6 7
attributes.push_back(/* float */);
attributes.push_back(/* string */);
// Now I need to know that attributes is a float to use it
I don't actually have a vector void. I have a vector<container> where container is a class which contains a type variable and a void pointer. But even if I know the type, don't I still have to cast the pointer back to the original type to use the data.