Getting an error that my pure virtual functions aren't defined, but they are

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.
* */
virtual void beginContact(FixtureUserData * thisFixUD,
            Collidable::Ptr thatCollidable,
            FixtureUserData * thatFixUD
            ) = 0;

/**
* @brief The collidable decides what it does upon ending contact.
* */
virtual void 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Ball : public jl::Actor {
public:

    Ball(string surname, jl::Level * level, std::vector<string> layerNames) : jl::Actor("ball" + surname,
            level, layerNames)
    {
         //some unrelated crap
    }

    void beginContact(FixtureUserData * thisFixUD, Collidable::Ptr thatCollidable, FixtureUserData * thatFixUD)
    {
        std::cout << name() << " has collided." << std::endl;
    }

    void endContact(FixtureUserData * thisFixUD, Collidable::Ptr thatCollidable, FixtureUserData * thatFixUD)
    {
        std::cout << name() << " is no longer colliding." << std::endl;
    }
};


Any ideas? Thank you in advance!
Please post the full Collidable.h file.
Is the Collidable class in the jl namespace?
If not, that's your problem.
Collidable is in the jl namespace. Here's Collidable.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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.
     * */
    virtual void beginContact(FixtureUserData * thisFixUD,
            Collidable::Ptr thatCollidable,
            FixtureUserData * thatFixUD
            ) = 0;

    /**
     * @brief The collidable decides what it does upon ending contact.
     * */
    virtual void 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...
Topic archived. No new replies allowed.