gpt4 book ai didi

C++ 没有构造函数 "Card::Card"的实例与参数列表匹配

转载 作者:太空宇宙 更新时间:2023-11-04 15:47:04 27 4
gpt4 key购买 nike

这是我的卡片结构头文件:

#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;
}

我怀疑是 Card(Suits, ranks) 中的类型冲突,但我不确定。任何输入将不胜感激!!!

最佳答案

v.push_back(Card(ten, hearts)); //got an error here 

难道这不是

v.push_back(Card(hearts, ten));

?

关于C++ 没有构造函数 "Card::Card"的实例与参数列表匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915500/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com