C++ 对';标准::基本字符串<;char>;::基本字符串c++;
嘿,我在做一个“做你自己的冒险游戏!”现在我想做一个作弊代码系统,现在我试图声明一个字符串巫婆等于超过6个单词,我不知道问题是什么,我只用了两个单词就完成了,没有错误。然而,当我用超过2个单词做同样的事时,我得到了错误 Main.cpp | 27 |错误:调用“std::basic_string::basic_string(常量字符[4],常量字符[6],常量字符[5],常量字符[5],常量字符[6],常量字符[6])时没有匹配的函数| 这是我的密码:C++ 对';标准::基本字符串<;char>;::基本字符串c++;,c++,string,compare,adventure,C++,String,Compare,Adventure,嘿,我在做一个“做你自己的冒险游戏!”现在我想做一个作弊代码系统,现在我试图声明一个字符串巫婆等于超过6个单词,我不知道问题是什么,我只用了两个单词就完成了,没有错误。然而,当我用超过2个单词做同样的事时,我得到了错误 Main.cpp | 27 |错误:调用“std::basic_string::basic_string(常量字符[4],常量字符[6],常量字符[5],常量字符[5],常量字符[6],常量字符[6])时没有匹配的函数| 这是我的密码: #include <iostream
#include <iostream>
//LVL1
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dog.h"
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dream.h"
#include "C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\GTFO.h"
using namespace std;
int Return();
int Continue();
int main(){
cout << "Welcome to my 'MAKE YOUR OWN ADVENTURE GAME!!!'\n";
cout << "Have Fun and enjoy the ride!\n";
cout << "Would you like to put in a cheat code??\n";
cout << "Yes or No, Cap Sensitive!\n";
Return();
return 0;
}
int Return(){
std::string y("Yes","No");
cin >> y;
if(y.compare("Yes")){
cout << "Please Enter Cheat Code now\n";
std::string z("Dog","Dream","GTFO","Path","Sword","Weird");
cin >> z;
if(z.compare("Dog")){
Dog();
}else if(z.compare("Dream")){
Dream();
}else if(z.compare("GTFO")){
GTFO();
}else if(z.compare("Path")){
Path();
}else if(z.compare("Sword")){
Sword();
}else if(z.compare("Weird")){
Weird();
}else{
cout << "Invalid Cheat Code\n";
}
}else if(y.compare("No")){
return Continue();
}else{
cout << "Invalid Answer!\n";
Continue();
}
}
int Continue(){
cout << endl;
cout << "You wake up and your house is on fire what do you do ??\n";
cout << "Quick Grab The Dog = 0, GTFO = 1, Go back to sleep = any other number\n";
int x;
cin >> x;
if(x == 0){
Dog();
}else if(x == 1){
GTFO();
}else{
Dream();
}
}
#包括
//1级
#包括“C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dog.h”
#包括“C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\Dream.h”
#包括“C:\Users\QuestionMark\Desktop\Make Your Own Adventure\LVL1\GTFO.h”
使用名称空间std;
int Return();
int Continue();
int main(){
cout您的问题在于字符串z的声明,您的代码是:
std::字符串z(“狗”、“梦”、“GTFO”、“路径”、“剑”、“怪异”);
编译器找不到包含6个参数的std::string的构造函数,请尝试
std::string z(“任意字符串”);
或者因为您将要初始化z
std::string z;
我不确定您想做什么,但请在std::string
上查找一个参考。还要注意=
。std::string没有包含六个参数的构造函数。也没有包含两个字符串的构造函数。您偶然发现的是迭代器对构造函数,wh如果你的程序运行,我可能会使它崩溃。