0

In C++, I have the following map array:

map<string, Module> modules;

And the following code to define the Module class:

class Module {
    public:
        const char** run();
};

And the following subclass that implements all required methods from it's parent:

class Wsiv : public Module {

And the following code block after the vector:

#ifndef NWSIV
    modules["wsiv"] = new Wsiv; // Add the WSIV module if it's not disabled at compile time.
#endif

But when I compile this all (I know everything is being included) it gives me this error:

../src/main.cpp:38:25: error: expected type-specifier before 'Wsiv'
   modules["wsiv"] = new Wsiv; // Add the WSIV module if it's not disabled at compile time
.
                         ^
../src/main.cpp:38:25: error: expected ';' before 'Wsiv'

Because Wsiv extends Module, I should be able to initialize an instance of Wsiv and assign it as a value in an array of Module classes. I should be able to cast one type to the other. How can I fix this?

Ethan McTague
  • 2,236
  • 3
  • 21
  • 53

0 Answers0