t3r*_*2d2 1 c++ vector header-files c++11
我有一个 Player 类,其中包含一个实例变量:\
vector<Card> userCards;
Run Code Online (Sandbox Code Playgroud)
为了避免任何编译错误,我向前声明了该类Card。但是现在当我尝试构建解决方案时,我收到一条错误消息
卡*:尺寸未知。
基本上我试图创建一个Player包含非固定数量的卡片的 who,所以我尝试使用向量,但现在我无法让它工作。
播放器.h
#include <iostream>
#include <vector>
using std::string;
using std::vector;
#ifndef PLAYER_H_
#define PLAYER_H_
class Card;
class Player {
private:
vector<Card> userCards;
};
#endif
Run Code Online (Sandbox Code Playgroud)
卡.h
#include <iostream>
using std::string;
#ifndef CARD_H_
#define CARD_H_
class Card {
private:
string name;
string type;
public:
Card(const string& name, const string& type);
};
#endif
Run Code Online (Sandbox Code Playgroud)
我有一堆不相关的不同功能,所以我没有包括它们。
| 归档时间: |
|
| 查看次数: |
10779 次 |
| 最近记录: |