這是我的卡結構的頭文件:C++的構造函數「卡::卡」沒有實例的參數列表匹配
#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卡成員變量:
#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;
}
我的懷疑是Card(套裝,等級)中的類型衝突,但我不確定。任何輸入將不勝感激!
非常感謝您,在編寫一些解析代碼後感到困惑。 – HoKy22 2013-02-16 21:56:56