在eclipse中调试c ++中的错误

时间:2013-03-17 13:10:48

标签: c++

你好,我在eclipse中工作过c ++ 在XO.h中

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的原型”   ,请帮帮我

1 个答案:

答案 0 :(得分:3)

我认为问题在于MaximizerMinimizer原型声明时start_playplay尚未知。将class 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中的原型与后面的函数定义不匹配,因为在声明原型的时候,MaximizerMinimizer还不是已知的类型,在你的功能定义时,它们是。