2

您好,我在 XO.h 中的 Eclipse 中使用了 c++

class Master
{
private:
char board[3][3];

public:
Master();
void change_board(int choice[1],char color);
void start_play(Maximizer,Minimizer);
void end(char winner);
char winner();
void play(Maximizer,Minimizer);

};

class Maximizer{};
class Minimizer{};

在 Xo.cpp

void Master::start_play(Maximizer x ,Minimizer o)
{play(x,o);
 }

但是 Eclipse 会生成一个“原型为void Master::start_play(Maximizer, Minimizer)' does not match any in class Master”的错误,请帮助我

4

1 回答 1

3

我认为问题在于Maximizerand的原型声明时andMinimizer还不是已知类型。向上移动到的定义之上。start_playplayclass Maximizer{};class Minimizer{};Master

class Maximizer{};
class Minimizer{};

class Master
{
private:
    char board[3][3];

public:
    Master();
    void change_board(int choice[1],char color);

    //above declaration of Maximizer and Minimizer required
    void start_play(Maximizer,Minimizer);

    void end(char winner);
    char winner();

    //above declaration of Maximizer and Minimizer required
    void play(Maximizer,Minimizer);

};

就目前而言,原型Master与您以后的函数定义不匹配,因为在声明原型时,Maximizer它们Minimizer还不是已知类型,而在定义函数时,它们是。

于 2013-03-17T13:29:51.390 回答