Class method goes undetected

  c++, visual-studio

I am a total novice in C++ world and programming in general. This is the first time I posted a question here and my first time using Visual Studio as well. I am trying to create a tic tac toe game in Visual Studio using C++. Here I’ve created the board and the player class.

The player class

#pragma once
#include <string>
#include <vector>
#include "Structs.h"
#include "Board.h"
#include "Cell.h"
class Player
{
    std::string name;
    Cursor cursor;
public:
    void ClaimCellAtCursor(Board& board);
    Player(std::string Name, Cell::Type _type);
    bool isFirstTurn;
    Cell::Type type;
};

// This function caused the first error message
Player::Player(std::string Name, Cell::Type _type) {
    cursor.locX = 0;
    cursor.locY = 0;
    isFirstTurn = false;
    name = Name;
    type = _type;
}

// Claim a selected cell. This function is what causing the second error message
// This function will be called by a game manager
void Player::ClaimCellAtCursor(Board& board)
{
    Cell target = board.SearchForCellAt(cursor);
    target.SetCell(*this);
}

and here I have the board class. It is unfinished, but I believe it won’t cause the error I’ve encountered.

#pragma once
#include "Cell.h"
#include "Structs.h"
#include "Player.h
#include <vector>
class Board
{
public:
    Cell& SearchForCellAt(Cursor location);
private:
    int size;
    std::vector<std::vector<Cell>> Cells;
};

// Search for a certain cell at cursor
Cell& Board::SearchForCellAt(Cursor location)
{
    // TODO: insert return statement here. 
}

I expect I will get an error message from here

Cell& Board::SearchForCellAt(Cursor location)
{
    // TODO: insert return statement here. 
}

But there was none. Instead I get these error messages

Severity Code Description Project File Line Suppression State Error
(active) E0493 no instance of overloaded function "Player::Player"
matches the specified
type TicTacToe C:UsersKeluargasourcereposTicTacToeTicTacToePlayer.h 25

Severity Code Description Project File Line Suppression State Error
(active) E0147 declaration is incompatible with "void
Player::ClaimCellAtCursor( &board)" (declared at line 41
of
"C:UsersKeluargasourcereposTicTacToeTicTacToePlayer.h") TicTacToe C:UsersKeluargasourcereposTicTacToeTicTacToePlayer.h 41

Which is weird. I don’t get what did I do wrong with these functions for them to be undetected like this. I have tried rewriting the function, unloading and reloading the solution, restarting Visual Studio, and copying them to another file and changing their names. But the problem persists. Is the problem lies in my code or is this a Visual Studio bug? What can I do to fix them?

Source: Windows Questions C++

LEAVE A COMMENT