Search code examples
c++juce

Abstract class type


I'm trying to initialize a class like this:

m_OSCListener = new OSC_Listener(*this, 12345);

But the compiler throws "Allocating an object of abstract class type 'OSC_Listener'" at me?

The class looks like this:

class MainComponent;

class OSC_Listener: public Thread, private MessageListener
{
public:
    OSC_Listener(MainComponent& owner_, int port);
    ~OSC_Listener();

    void handleMessage (const Meddelande& message);
    void run();

private:
    int m_Port;

    ScopedPointer <MemoryBlock>     messageData;
    ScopedPointer <DatagramSocket>  socket;

    MainComponent& owner;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSC_Listener);
};

Why is this?


Solution

  • Juce::MessageListener has an abstract virtual function you need to override:

    http://www.juce.com/api/classMessageListener.html

    add this to your class:

    virtual void handleMessage (const Message &message) {}