Search code examples
c++functionclassvirtual

Defining virtual void with a boolean pointer as an argument throws error


consider two C++ classes:

class cTextbox : public cControl{
public:
    ...
protected:
    void onUpdate(bool* keys);
}

class cControl{
public:
    ...
protected:
    virtual void onUpdate(bool*) = 0;
}

This returns me an error C2504: 'cControl': base class undefined when I define it in the CPP file. Is it possible that I cannot pass a pointer as an argument to a virtual function?


Solution

  • This has nothing to do with your virtual function, or boolean argument.

    At the point that you defined cTextBox, cControl doesn't exist yet, so you can't use it as a base. That's why the error message says the base class is undefined: cControl, the base class, is undefined.

    Define cControl first.