Blowing My Foot Off

After a few days of not being able to get Chimera to compile because of some seemingly obtuse compiler error, I’ve finally got it building and it was down to a schoolboy error.

I have a pure virtual base class called GameObject, from which I derive objects like Entity, Player and Block. The compiler kept telling me that I couldn’t instantiate Player, because it was an abstract class.

I looked at the GameObject class over and over and couldn’t see what was wrong.

class GameObject
{
public:
virtual ~GameObject();
virtual void update(float) = 0;
virtual void draw() const = 0;

protected:
ci::Vec3f position_;
ci::Vec3f size_;
};

Well take a look at that const. Looks innocuous enough, but in the classes I decided to over-ride draw() for, I forgot to use the const, which meant that as far as the compiler was concerned, I hadn’t implemented that exact function. And of course, I hadn’t. Took me ages to spot, but the compiler was right and I just wasn’t looking hard enough.