Hi there. I'm just trying to compile a simple little application to test a library that I'm working on.
I'm getting an error that two pure virtual functions within a base class I've called "Collidable," are not defined within the subclass I'm trying to define called "Ball."
However, I have indeed defined those two functions with the same parameters as required by the base class's definition. Any idea what's wrong?
Here is the declaration of the two functions in the base class, Collidable.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
* @brief The collidable decides what it does upon starting contact.
* */
virtualvoid beginContact(FixtureUserData * thisFixUD,
Collidable::Ptr thatCollidable,
FixtureUserData * thatFixUD
) = 0;
/**
* @brief The collidable decides what it does upon ending contact.
* */
virtualvoid endContact(FixtureUserData * thisFixUD,
Collidable::Ptr thatCollidable,
FixtureUserData * thatFixUD
) = 0;
And here is their temporary implementation in the Ball class, which extends Collidable (although there are two subclasses inbetween). Note: The ball class is being defined in main.cpp.
// Copyright (c) 2012 Happy Rock Studios
#ifndef JL_COLLIDABLE_H
#define JL_COLLIDABLE_H
#include <string>
#include "fwk/NamedInterface.h"
#include "fwk/Ptr.h"
using std::string;
namespace jl
{
class FixtureUserData;
class Level;
/*!
* @brief Any object that can be used with collision detection.
* @details This object has a b2Body, but not a jl::Body. The collision manager
* casts all objects as Collidable's.
* */
class Collidable : public fwk::NamedInterface
{
public:
typedef fwk::Ptr<Collidable> Ptr;
Collidable(string name, Level * level) : fwk::NamedInterface(name),
_level(level) { }
// --- Accessors and mutators
Level * level() const { return _level; }
/**
* @brief The collidable decides what it does upon starting contact.
* */
virtualvoid beginContact(FixtureUserData * thisFixUD,
Collidable::Ptr thatCollidable,
FixtureUserData * thatFixUD
) = 0;
/**
* @brief The collidable decides what it does upon ending contact.
* */
virtualvoid endContact(FixtureUserData * thisFixUD,
Collidable::Ptr thatCollidable,
FixtureUserData * thatFixUD
) = 0;
private:
/// Backpointer to the level in which this entity lives.
Level * _level;
};
} // namespace jl
#endif
Figured it out. I had to specify in Ball's declaration of the methods that the FixtureUserData class (which is defined in neither of these files) was part of the jl namespace. This should have been obvious. Just one of those days...