Veröffentlicht 23. November 201014 j Guten Abend, dies ist höchst warscheinlich ein denkbar einfach zu lösendes Problem, allerdings komme ich nicht ganz dahinter. (Ich nutze den VSC++ Compiler) Wenn ich ein Objekt der Klasse Bow erzeugen möchte, teilt mir der Compiler mit das für eben diese Klasse ein geeigneter Standartkonstruktor verfügbar ist. Ich verstehe das nicht, da ich zum einen, einen Konstruktor sowie einen destruktor bereitstelle. class Bow { string color; bool drawn; int numOfArrows; public: Bow(string aColor); ~Bow(); void draw(); int fire(); }; Bow::Bow(string aColor) { using std::srand; using std::time; numOfArrows = 10; drawn = false; color = aColor; srand(time(0)); } Bow::~Bow() { } int Bow::fire() { using std::cout; using std::rand; if(!drawn) { cout << color << " has not been drawn " << "and therefore could not fire.\n"; return 0; } int score; score = rand() % (10 - 0 + 1) + 0; if(score == 0) cout << color << " missed the target!!!\n"; else cout << color << " scored " << score << " points!!!\n"; return score; } void Bow::draw() { using std::cout; drawn = true; cout << "The " << color << " bow has been drawn.\n"; } lg Gateway
23. November 201014 j Autor sry hat sich schon erledigt. lg Gateway edit: @Guybrush Threepwood: Exakt da lag das Problem .
Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.