Java-like instanceof Oct 04, 2009 |
|---|
So I was hoping c++ had a Java-like instanceof function. It didnt as far as I could find... Lame. Instead I have to include an enumerated value in all of my subclasses to determine which subclass of a light i am dealing with... This sucks.
enum type {AMBIENT, DIFFUSE, PHONG};
class Light{
public:
Light(unsigned int color, float strength, type lightType);
unsigned int getColor();
type getType();
virtual void update(vector meshes);
protected:
type lightType;
unsigned int color;
float strength;
};
Thoughts, anyone? Is there a better way? |
|
| Leave a Comment |
| |