嘿,我正在製作一個「製作你自己的冒險遊戲!」現在,其他人不得不通過洞穴遊戲來製作一個作弊代碼系統,現在我試圖宣佈一個字符串女巫等於超過6個字我不明白問題是什麼我只用兩個並沒有任何錯誤,當我用超過2個單詞做同樣的事情時,我得到了錯誤。調用'std :: basic_string :: basic_string(const char [4],const char [6],const char [5],const char [5])時沒有匹配函數。 ,const char [6],const char [6])'|沒有匹配函數調用'std :: basic_string <char> :: basic_string C++
這裏是我的代碼:
#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();
}
}
我不知道你想做什麼,但查找在'的std :: string'參考。請注意'=='。 – chris
沒有帶六個參數的std :: string的構造函數。 – 2013-11-29 03:48:23
也沒有構造函數需要兩個字符串。你偶然碰到的那個是迭代器對構造函數,它應該會在程序運行時崩潰。 – chris