小编Cay*_*ira的帖子

如何使用抽象对象数组?无效的抽象类型错误

我正在用C ++编写国际象棋游戏,而Player具有16个棋子的数组,这是每个棋子(马,兵,国王等)的抽象类。编译器给我一个“ pecas”无效的抽象类型“ Peca”。我在做什么错?谢谢!

播放器

#include "Peca.h" // Includes Piece abstract class

using std::string;

class Jogador
{
    private:
        static int numeroDeJogador; //PlayerNumber (0-1)
        string nome;
        Peca pecas[16]; //This is the array of the abstract class Pecas (Pieces), where i want to put derived objects like Horse, king..

    public:
        string getNomeJogador(); // Return the player name

};
Run Code Online (Sandbox Code Playgroud)

件数

#ifndef PECA_H
#define PECA_H
#include <string>

using std::string;

class Peca {

    private:
        int cor; //0 para as brancas, 1 …
Run Code Online (Sandbox Code Playgroud)

c++ oop abstract

1
推荐指数
1
解决办法
52
查看次数

标签 统计

abstract ×1

c++ ×1

oop ×1