Anfängerfehler?
-
Hallo zusammen, ich suche jetzt schon seit tagen den Fehler, kann ihn jedoch nicht finden und bitte die Profis um Hilfe. Bin in meinem buch (C++ Alles in einem Band Für Dummies)gerade bei den geerbten Mitgliedern angekommen, hab den Code vom Buch abgetippt.
Folgender Fehler Leuchtet in der Zeile:
class FrozenPizza : public FrozenFood
auf:
Error:Incomplete type ist not allowed. (da ist FrozenFood gemeint.)
Ich hab euch noch den gesamten Code kopiert und hoffe ihr könnt mir weiterhelfen.
Danke schon im vorraus, aircross-u-fly
#include <iostream> using namespace std; class FrozenFood { private: int Price; protected: int Weight; public: FrozenFood(int APrice, int AWeight) { int GetPrice(); int GetWeight(); }; class FrozenPizza : public FrozenFood //Error: Incomplete type is not allowed { protected: int Diameter; public: FrozenPizza(int APrice, int AWeight, int ADiameter); void DumpInfo(); }; class DeepDishPizza : public FrozenPizza { private: int Height; public: DeepDishPizza(int APrice, int AWeight, int ADiameter, int AHeight); void DumpDensity(); }; FrozenFood::FrozenFood(int APrice, int AWeight) { Price = APrice; Weight = AWeight; } int FrozenFood::GetPrice() { return Price; } int FrozenFood::GetWeight() { return Weight; } FrozenPizza::FrozenPizza(int APrice, int AWeight, int ADiameter) :FrozenFood(APrice, AWeight) { Diameter = ADiameter; } void FrozenPizza::DumpInfo() { cout << "\tFrozen pizza info:" << endl; cout << "\t\tWeight: " << Weight << " ounces" << endl; cout << "\t\tDiameter: " << Diameter << " inches" << endl; } DeepDishPizza::DeepDishPizza(int APrice, int AWeight, int ADiameter, int AHeight) : FrozenPizza(APrice, AWeight, ADiameter) { Height = AHeight; } void DeepDishPizza::DumpDensity() { // Calculate pounds per cubic foot of deep-dish pizza cout << "\tDensity: " << cout << Weight * 12 * 12 * 12 * 14 / (Height * Diameter * 22 * 16); cout << " pounds per cubic foot" << endl; } }; int main(int argc, char *argv[]) { cout << "Thin crust pepperoni" << endl; FrozenPizza pepperoni(450, 12, 14); cout << "\tPrice: " << pepperoni.GetPrice() << " cents" << endl; cout << "Deep dish extra-cheese" << endl; DeepDishPizza extracheese(650, 21592, 14, 3); extracheese.DumpInfo(); extracheese.DumpDensity(); cout << "\tPrice: " << extracheese.GetPrice() << " cents" << endl; return 0; }
-
Die { am Ende hat keine passende }
FrozenFood(int APrice, int AWeight) {
Vermutlich gehört sie da nicht hin.
-
ausserdem hast du über der main noch ein }; was da irgendwie auch nicht hinpasst...
-
Vielen Dank für die schnelle Antwort, hat geklappt
danke
-
Cherup: Ja, hab ich gesehen und auch gleich behoben den fehler, danke