'Illegal member initialization in C++

class ZooAnimal {
public:
    virtual void draw();
    int resolveType() {return myType;}
protected:
    int myType;
};

class Bear : public ZooAnimal {
public:
    Bear (const char *name) : myName(name), myType(1){}
    void draw(){ };
private:
    std::string myName;
};

void main()
{
   
}

When I am compiling above code I am geeting following error

error C2614: 'Bear' : illegal member initialization: 'myType' is not a base or member

Why am I getting the above error, as we can access protected member from the derived class?

c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source