Having trouble with new Header and .cpp

As far as i can tell i have everything typed up that same as is shown in the videos, but i’m getting an error saying that the variable are not a function but without the () they show another error.

if somebody could give me a clue on what i’m doing wrong with the definition it’s be much appreciated.

So in your .cpp you are treating MyCurrentTry and MyMaxTries as functions…But if you check your header file you can see that these are just private variables that you have already initialized to 1 and 5 respectively. These variables are there to be used by say…your getter functions in the public methods of your class. To get your error to go away simply delete in your .cpp file twhere you try implement your variables as methods…Basically delete everything below your CheckGuessValidity method… Hope that helps.

I am no pro but I think I can help you out.

You cannot use them like this and you don’t need to.
So remove fBullCowGame::MyCurrentTry() and fBullCowGame::MyMaxTries.
Maybe you should just do that, don’t read the following explanation and keep following the videos.

These are private variables of your header.
When needs be you can modify them from the fBullCowGame.h,inside class FBullCowGame, under private:
example:
(in the file FBullCowGame.h)
class FBullCowGame {
public:

private:
int32 MyCurrentTry = 10;
};

or in fBullCowGame.cpp, inside a function definition
example:
(inside fBullCowGame.cpp)
void fbullCowGame::Example()
{
MyCurrentTry = 3;
}

But you need to declare the function inside your fBullCowGame.h first
(inside fBullCowGame.h)
class FBullCowGame {
public:
Example();

private:

};

These are private because you don’t want to mess up the system your building.

Privacy & Terms