Bulls and Cows - Why did we declare the IsIsogram function in the private scope?

Hi,
So this the Unreal Engine course before the remastering. I’m currently on section 2 (Bulls and Cows) - lecture 52

I just had a simple question, why did Ben decide to declare the IsIsogram prototype in the private section of the FBullCowGame Class? why not public, what difference does it make?

It’s kind of hard to understand at this stage but It’s an accessor level.
You have public, protected, and private.

public - can be accessed anywhere
protected - can only be accessed by the class itself and derived classes
private can only be accessed by the class itself.

Here’s a code example

class A
{
public:
    void Public();
protected:
    void Protected();
private:
    void Private();
}

class B : public A
{
    void Foo() 
    {
        Public(); //okay inherited from A and accessible
        Protected(); //okay inherited from A and accessible
        Private();//error inherited from A and inaccessible
    }
};

int main()
{
    A a;
    a.Public(); //ok
    a.Protected(); //error inaccessible
    a.Private(); //error inaccessible
}

This isn’t what I meant, I know what these accessors do, I was asking why he decided to put the IsIsogram function in the private accessor level, why not public with the rest of the functions

Because it’s an implementation detail for CheckGuessValidity. Users shouldn’t need to know about it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms