这是我的 Card 结构头文件:
#include "stdafx.h"
enum Suits {clubs, diamonds, hearts, spades};
enum Ranks {two = 2, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace};
struct Card {
Card (Suits suit, Ranks rank);
private:
Suits suit_;
Ranks rank_;
};
我在我的 cpp 中初始化 Card 成员变量:
#include "stdafx.h"
#include "Card.h"
#include "Header.h"
using namespace std;
Card::Card (Suits suit, Ranks rank) : suit_(suit), rank_(rank) {}
现在,我正在尝试在一个函数中解析一堆卡定义字符串,例如 2C、3h、7s、10h
int FileParsing(vector<Card> & v, char * FileName) {
... //omiting the details, basically open FileName, parse card definition strings
//After I finish parsing 10h, I tried to push it back
v.push_back(Card(ten, hearts)); //got an error here
...
return 0;
}
我的怀疑是卡片(西装,等级)中的类型冲突,但我不确定。任何输入将不胜感激!!!