C2761 error: Member function redeclaration not allowed

Hi, revisiting this course after a year’s break and noted I had the following error:

Error C2761 ‘bool FBullCowGame::IsGameWon(void) const’: member function redeclaration not allowed.

Have tried a few things and looked online but am drawing blanks. I have pasted the two files which use the const below. Any help / ideas would be appreciated.

Thanks,

Mike

header file:

#pragma once
#include <string>

using FString = std::string;
using int32 = int;

struct  FBullCowCount 
{
	int32 Bulls = 0;
	int32 Cows = 0;
};

class FBullCowGame 
{
public:
	FBullCowGame(); //constructor

	int32 GetMaxTries() const;
	int32 GetCurrentTry() const;
	bool IsGameWon() const;

	void Reset(); //TODO Make a more rich return value.
	bool CheckGuessValidity(FString); //TODO make a morr rich return value
	// provide a method for counting bulls and cows and increasing try assu,ing valid guess#
	FBullCowCount SubmitGuess(FString);

//Focus on interface above not this
private:
	// see constructor for insilisation
	int32 MyCurrentTry;
	int32 MyMaxTries;
	FString MyHiddenWord;
};

FBullCowGame.cpp

#include "FBullcowgame.h"

using int32 = int;
using FString = std::string;

FBullCowGame::FBullCowGame()
{
	Reset();
}

int32 FBullCowGame::GetMaxTries() const { return MyMaxTries; }
int32 FBullCowGame::GetCurrentTry() const { return MyCurrentTry; }


void FBullCowGame::Reset()
{
	constexpr int32 MAX_TRIES = 8;
	MyMaxTries = MAX_TRIES;

	const FString HIDDEN_WORD = "planet";
	MyHiddenWord = HIDDEN_WORD;
	MyCurrentTry = 1;
	return;
	//std::cout << "You have " << MAX_TRIES << " guesses.";
}


bool FBullCowGame::IsGameWon() const
{
	return false;
}

	//TODO return true if Guess = isogram



bool FBullCowGame::CheckGuessValidity(FString)
{
	//TODO Compare guess length to word length and return false if do not match.
	return false;
}
// receives a valid guess, increments turns and returns count
FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
{
	// increment the turn number
	MyCurrentTry++;

	//setup a return variable
	FBullCowCount BullCowCount;

	// loop through all the letters in the guess
	int32 HiddenWordLength = MyHiddenWord.length();
	for (int32 MHWChar = 0; MHWChar < HiddenWordLength; MHWChar++) 
	{
		// compare letters against the hidden word
		for (int32 GChar = 0; GChar < HiddenWordLength; GChar++) 
		{
			//if they match increments bulls 
			if (Guess[MHWChar] == MyHiddenWord[MHWChar]) {
				if (MHWChar == GChar) {
					BullCowCount.Bulls++;
				}
				//if they are in the same place else increment cows
				else {
					BullCowCount.Cows++;
				}
			}
		}
	}
	return BullCowCount;

Privacy & Terms