Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Function is Inaccessible

Tags:

c++

I am wondering why this function is inaccessible.

The function:

class SERVER_DECL EventableObject
{

protected:
    void RemoveEvent(TimedEvent * ev);
};

Here is what I have:

Event * ReadyUp;
void Start()
{
    static uint8 Tick = 1;

    if(Tick == 1)
    {
        NormalMessage("Starting Event..");
    }
    EventableObject.RemoveEvent(this->ReadyUp); // Inaccessible
}

EventableObject.RemoveEvent(this->BattlefieldReadyUp); // Inaccessible

Is where I'm getting the error.

like image 215
user795232 Avatar asked Oct 21 '25 19:10

user795232


2 Answers

It's inaccessible because it's protected instead of public.

protected means you can access it only from within the same, or a derived, class. Since you didn't indicate where your code was located, I'll just assume it is neither of those.

like image 55
Jonathan Wood Avatar answered Oct 23 '25 10:10

Jonathan Wood


A protected function in a C++ can only be accessed by the class itself and derived classes, not outside the class, hence you're getting the error message that the function is inaccessible.

like image 24
Timo Geusch Avatar answered Oct 23 '25 09:10

Timo Geusch