keine passende Funktion für Aufruf von " std::basic_string<char>::basic_string c++
Hey, ich mache ein "Make your own-Abenteuer-Spiel!" Jetzt anderen müssen dann führen Sie durch das Loch, das Spiel wollte ich einen cheat-code-system und jetzt versuche ich, zu deklarieren Sie eine string-Hexe ist gleich über 6 Wörter die ich nicht sehe, was das problem ist, ich habe es mit nur zwei Worten-und bekam keine Fehler, wie immer, wenn ich Tat das gleiche mit mehr dann 2 Wörter, und ich habe den Fehler.
Main.cpp|27|Fehler: keine passende Funktion für Aufruf von " std::basic_string::basic_string(const char [4], const char [6], const char [5], const char [5], const char [6], const char [6])'|
Hier ist mein code:
#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();
}
}
- Ich bin mir nicht sicher, was Sie zu tun versuchen, sondern eine Referenz auf
std::string
. Beachten Sie==
als gut. - Es gibt keinen Konstruktor für std::string, dauert sechs Argumente.
- Es gibt auch keinen Konstruktor der Einnahme von zwei strings. Die, die Sie zufällig auf der iterator-pair-Konstruktor, der sollte wahrscheinlich zu einem Absturz das Programm sollte es laufen.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dein problem ist hier in Ihrer Erklärung der Zeichenfolge z, code :
std::string z("Dog","Dream","GTFO","Path","Sword","Weird");
Ihr compiler Sie nicht finden kann ein Konstruktor für std::string, dauert 6 Argumente versuchen, statt
std::string z("any string");
oder weil Sie zu initialisieren z nur
std::string z;