Most Efficient Way to Do This?
I'm creating a game. I have a base Image class, with derived Decal and Primitive classes. I also have a seperate class named Frame that holds all Decals and Primitives. What's the best way to go about doing this? I originally thought about making dynamic arrays within the Frame for each base and derived class. For example:
Code:
class Frame{
//vector for Decals
//vector for Primitives
};
However, I thought that this was very inefficient. I want to have a single member method in the Frame class that could take Decals, Primitives, and any new image types I may want to create. I figured a template function would be best for this. However, I'd have to do a specialization for each and every applicable type, as each one would be stored in a different array. Would I be better off doing this mess, or should I cast all of the derived ImageObjects into the base, and then store that in a dynamic array? Problem is, converting them back is never a good idea... ugh, can anyone help me out here? Is there something I'm missing?