"JOUER"という機能に少し問題があります。 私はそれに取り組んでいるのは数日ですが、私は問題を見ることができません。 主な問題は次のとおりです。[エラー] 'char'の前に 'int'および[Error]の前に予期されたprimary-expressionが必要です。あなたのコード内のいくつかの問題がありC++のTicTacToeゲームの私の機能の1つ
#include <iostream>
using namespace std;
enum etat { victoire, continuer, null };
int qntMouv = 0;
class TicTacToe {
public:
TicTacToe();
etat etatJeux();
void affichTab() const ;
bool getXOMouv (char symbolMouv);
bool mouvValid (int x, int y) const;
void recommence();
void game();
void jouer();
private:
char tableau[3][3];
}; // fin classe TicTacToe
TicTacToe::TicTacToe()
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
tableau[i][j] = ' ';
qntMouv = 0; // le tableau est vide
} // fin constructeur TicTacToe
bool TicTacToe::mouvValid (int x, int y) const{
int lig, col;
if (lig >= 0 && lig <= 2 && col >=0 && col <= 2 && tableau[x] [y] == ' ')
return true;
else return false;
} // fin du bool mouvValid
etat TicTacToe::etatJeux() {
if ((tableau[0][0]) && (tableau[1][0]) && (tableau[2][0])) return victoire; //colomne
else if ((tableau[0][1]) && (tableau[1][1]) && (tableau[2][1])) return victoire; //colomne
else if ((tableau[0][2]) && (tableau[1][2]) && (tableau[2][2])) return victoire; // colomne
else if((tableau[0][0]) && (tableau[0][1]) && (tableau[0][2]))return victoire; // lignme
else if ((tableau[1][0]) && (tableau[1][1]) && (tableau[1][2])) return victoire; // ligne
else if ((tableau[2][0]) && (tableau[2][1]) && (tableau[2][2])) return victoire; // ligne
else if ((tableau[0][0]) && (tableau[1][1]) && (tableau[2][2])) return victoire; // diago
else if ((tableau[0][2]) && (tableau[1][1]) && (tableau[2][0])) return victoire; // // diago
else if (qntMouv < 9) return continuer;
return null;
} // fin etatJeux
void TicTacToe::recommence() {
qntMouv = 0;
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
tableau[i][j] = ' ';
} // fin recommence
どうしたのですか? – Rakete1111
[エラー]メンバー関数 'void TicTacToe :: affichTab()const'をオブジェクトなしで呼び出すことはできません – Sorel
エラーとは、その内容を意味します。ここで 'TicTacToe :: affichTab();'あなたはオブジェクトなしで関数を呼び出そうとしています。メソッドを静的にするかオブジェクト上で呼び出す – user463035818