Hi, I have an abstract class like this:

class Descriptor
{
    public:
        virtual ULONG dispatch(char*, size_t, Stream) = 0;
};

and I have a subclass like this:

class ConsoleShell : public Descriptor
{
    public:
        ULONG dispatch(char*, size_t, Stream*);
};

#include "services/console/Console.cpp"

and in Console.cpp:

ULONG ConsoleShell::dispatch(char *cmd, size_t len, Stream *s)
{
    return (ACE_OS::strcmp(cmd, "quit") == 0) ? s->close() : s->printf(cmd);
}

So I would think I'm all set to instantiate ConsoleShell, but I gcc gives me this:

/export/home/levk/r6/services/console/Console.cpp: In member function `ULONG
Console<Connection, Address>::start() [with Connection = LSOCKConnection,
Address = ACE_UNIX_Addr]':
/export/home/levk/r6/utility/connection/LSOCKConnection.h:17: instantiated from here
/export/home/levk/r6/services/console/Console.cpp:38: error: cannot allocate an
object of type `ConsoleShell'
/export/home/levk/r6/services/console/Console.cpp:38: error: because the
following virtual functions are abstract:
/export/home/levk/r6/utility/connection/Connection.h:71: error: virtual ULONG
Descriptor::dispatch(char*, unsigned int, Stream)

Where Console.cpp:38 is where I'm trying to instantiate ConsoleShell and Connection.h:71 is Descriptor::dispatch

Am I missing something syntactically from the snippet I just gave you?

Thank you in advance

derived class declaration of the pure virtual function must be EXACTLY like that in the base class, minus the "= 0" part. You forgot the word virtual in the derived class. I find it easy to prevent that kind of error by copy-past from base class to derived class.

You forgot the word virtual in the derived class.

I tried that, I still get the same error. BTW, I'm instantiating ConsoleShell using new if that matters at all

also check other spellings -- base class has Stream parameter, but derived class shows Stream*. I suspect base class is incorrect.

THAT WAS IT!!! Thank You!!! I always mess these things up

>super
And the point of bumping a year-old thread to say that is exactly what...?

Either he found the solution to his own problem or he is referring to Java's super class... ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.