Errors on while statement on void PlayGame() Function

Severity Code Description Project File Line Suppression State
Error C2446 ‘<=’: no conversion from ‘int32’ to ‘int32 (__thiscall FBullCowGame::* )(void) const’ BullCowGame d:\projects\unrealengine\solution_02\bullcowgame\main.cpp 51

Severity Code Description Project File Line Suppression State
Error C3867 ‘FBullCowGame::GetCurrentTry’: non-standard syntax; use ‘&’ to create a pointer to member BullCowGame d:\projects\unrealengine\solution_02\bullcowgame\main.cpp 51

I noticed a couple things that might help:

  1. In the while statement, is GetCurrentTry a function? If so, you’ll need the parenthesis () at the end. If it’s NOT a function, I recommend renaming to just CurrentTryNumber (or something similar), as members that start with Get or Set are generally reserved for member functions rather than member variables. If the previous sentence doesn’t make sense, don’t worry about it, it’s just a style recommendation.

  2. Based on the error message, it seems like you’re trying to compare a pointer-type object to an integer. So look at your while statement. There are three objects being used:

    • the return value of BCGame.IsGameWon()
    • the return value of BCGame.GetCurrentTry
    • MaxTries

Based on the second error, specifically the characters ‘<=’ included in this error, I’m going to guess the problem is with one of the latter two objects because those are the two being compared. So, take a look at these two objects in your code. I’m thinking one of them is actually a pointer to an int instead of a plain int.

Hope this helps. If you’re still having trouble, feel free to post more screenshots!

Privacy & Terms