Insane Amount of Class/Header File Related Errors
I can't figure this out.
Here's my class/header, and Visual studio Output.
Injection point/instantiation.
1 2 3
|
int main()
{
Player player;
|
Call to a public method:
1 2 3 4
|
while(!isWin("x", board) && !isWin("o", board) && whoGoesFirst == "p")
{
printBoard(board);
board = player.playerTurn(board);
|
Header file:
1 2 3 4 5 6 7 8 9 10 11
|
#pragma once
#include <iostream>
#include <vector>
#include <string>
class Player
{
public:
Player();
vector<vector<string>> Player::playerTurn(vector<vector<string>> board);
};
|
CPP file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include "Player.h"
using namespace std;
// Binary scope resolution operator (::).
Player::Player()
{
// Empty constructor.
}
// Method to validate and execute the Player's turn.
vector<vector<string>> Player::playerTurn(vector<vector<string>> board)
{
string input;
while(input == "null")
{
cout << "Please pick a number:" << endl;
cin >> input;
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
if (input == board[i][j])
{
board[i][j] = "x";
cout << endl;
return board;
}
}
}
cout << "Invalid entry." << endl;
input = "null";
}
return board;
}
|
Output:
1 2 3 4
|
1
|
1> Player.cpp
1>c:\users\nscc\documents\visual studio 2012\projects\prog 2100 - assignment 1\prog 2100 - assignment 1\player.h(10): error C2143: syntax error : missing ';' before '<'
1>c:\users\nscc\documents\visual studio 2012\projects\prog 2100 - assignment 1\prog 2100 - assignment 1\player.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\nscc\documents\visual studio 2012\projects\prog 2100 - assignment 1\prog 2100 - assignment 1\player.h(10): error C2238: unexpected token(s) preceding ';' |
What the heck???
You seem to have missed the namespace specification for your vector, it's "std::vector...".
Oh! For goodness sake!
Thank you.
It's running great now. :D
Topic archived. No new replies allowed.