Initialisator schlägt fehl
-
hi,
ich hab ein Problem mit meinem Initialisator von meiner Klasse Zahl:
class Zahl { private: int Wert; bool Prim; public: Zahl (int, bool); }; Zahl::Zahl (int i, bool b); { Wert = i; Prim = b; }Mehr Code hab ich noch nicht geschrieben. Nur eine Test-Klasse hab ich initialisiert. Trotzdem bekomme ich folgenden Fehler:
In file included from prim.cpp:1: zahl.hpp:9: error: declaration of `Zahl::Zahl(int, bool)' outside of class is not definition zahl.hpp:10: error: parse error before `{' token zahl.hpp:12: error: ISO C++ forbids declaration of `Prim' with no type zahl.hpp:12: error: `b' was not declared in this scope zahl.hpp:13: error: parse error before `}' tokenWas soll das heißen?
Vielen Dank im vorraus
Joachim
-
Hallo
class Zahl { private: int Wert; bool Prim; public: Zahl (int, bool); }; Zahl::Zahl (int i, bool b); { Wert = i; Prim = b; }Mach das Semikolon nach folgender Zeile weg:
Zahl::Zahl (int i, bool b)und nutz Parameterlisten:
Zahl::Zahl: Wert(i), Prim(b) { }Hoffe, dass das so klappt.
chrische