FBullCowGame.cpp gives me an error altho I have FBullCowGame.h written just like shown in class

Greetings, I just got to an error when trying to follow this class instructions, as it is shown below.
I would greatly appreciate if someone could enlighten me as I cannot see where lies the problem.


You’re declaring MyCurrentTry and MyMaxRetries as private member VARIABLES but then you define them as member FUNCTIONS. From the context I think you want to delete the function definitions.

1 Like

Thank you for your reply, but I quite didn’t understand yet. Could you please give me a pratical example?

In FBullCowGame.cpp replace MyCurrentTry and MyMaxTries with GetCurrentTry and GetMaxTries respectively.

Sure, I’ll try.

FBullCowGame is a class, as a class it has member functions and member variables, in the .h file functions and variables are declared, functions make use of parentheses and variables don’t. Functions can be though of as sequences of instructions were variables are memory slots where you store values.

in your FBullCowGame.h file you declare the following functions:

Reset()
GetMaxTries()
GetCurrentTry()
CheckGuessValidity(…)
IsGameWon()

and you have the following variables:

MyCurrentTry
MyMaxTries.

BUT then in your definition file (the .cpp file) you try to define your variables as if they were functions:

FBullCowGame::MyCurrentTry()
FBullCowGame::MyMaxTries()

So, thats what is wrong, as OldDauber said, you need to change the CPP to have

FBullCowGame::GetCurrentTry()
FBullCowGame::GetMaxTries()

instead.

Hope that helps :slightly_smiling_face:

Privacy & Terms