dimanche 15 mars 2020

LNK2019 unresolved external symbol "void __cdecl playAt(void)" (?playAt@@YAXXZ) referenced in function _main [duplicate]

I am receiving an unresolved error that I have tried to solve but I do not know how to fix the problem it is saying "Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "void __cdecl playAt(void)" (?playAt@@YAXXZ) referenced in function _main Project1 C:\Users\David\Documents\functions first\Project1\Project1\Source.obj 1"

#include<Windows.h>
#include<iostream>
#include<vector>

using namespace std;

//specify the default value to fill the vector elements
int mapSize = 0;


int row = 0;
int column = 0;
int x = row = 0;
int y = column = 0;
int horizontal = 0;
int vertical = 0;
int player = 0;


std::vector<std::vector<char>> board;
void play();
void playAt();
bool hasLegalMoveFor(bool);

int main()
{
cout << "Enter the size of board. It should accept any size between 2 and 15. => ";
cin >> mapSize;

vector< vector<char> > board(mapSize, vector<char>(mapSize, '0'));
for (int i = 0; i < mapSize; i++) {
    for (int j = 0; j < mapSize; j++) {
        cout << board[i][j] << " ";
    }
    cout << endl;

play();
playAt();
return 0;
}
}

int CheckValid(int i, int j, int player) {

if (board[x][y] != 0)
    return 0;
if (player == 1) {
    if (board[x][y + 1] != 0 || y == 12)
        return 0;
}
else {
    if (board[x + 1][y] != 0 || x == 12)
        return 0;
}
return 1;
}

void play()
{
bool player = horizontal;
while (true) {
    cout << ("\n");
    if (player == horizontal) {
        cout << ("Horizontal to play");
    }
    else {
        cout << ("Vertical to play");
    }
    if (!hasLegalMoveFor(player)) {
    cout << ("No legal moves -- you lose! ");
    return;
    }
    cout << ("Rows: ");
    int row;
    cin >> row;
    cout << ("Column: ");
    int column;
    cin >> column;
    //playAt(row, column, player);
    player = !player;
}
  }

  void playAt(int x, int y, bool player) {
if (!board[x][y] && !board[x][y + 1] && player == horizontal) {
    board[x][y] = true;
    board[x][y + 1] = true;
}
else if (board[x][y] && !board[x + 1][y] && player == vertical) {
    board[x][y] = true;
    board[x + 1][y] = true;
}else {
    cout << ("Not a legal move!");
}
    }

    bool hasLegalMoveFor(bool player) {
int rowOffset = 0;
int columnOffset = 0;
if (player == horizontal) {
    columnOffset = 1;
}
else {
    rowOffset = 1;
}
for (int x = 0; row < (8 - rowOffset); x++) {
    for (int y = 0; y < (8 - columnOffset); y++) {
        if (!(board[x][y] = board[x + rowOffset][y + columnOffset])) {
            return true;
        }
    };
}
return false;
    }

Aucun commentaire:

Enregistrer un commentaire