Hi, I'm writing a program for an assignment at the moment requiring inheritance and dynamic objects.
I'm having problems working out how to declare a pointer in the class rooms. Neither my notes, or my teacher seem to be able to tell me how to do this.Originally Posted by Part of the program spec
Heres my classes:
When i compile I get an error message saying that I cant declare 'guests' without a type. How then would I declare a pointer in an object, or is this all just plain wrong?Code:class rooms { private: int number; float cost; guests *p; //This wont work public: rooms(); ~rooms(); int GetNumber(); float GetCost(); void SetNumber(int); void SetCost(float); void AddGuest(); }; class guests : rooms //guests are derived from rooms { private: char surname[10]; int bill; public: guests(); ~guests(); void EndGuest(); char* GetName(); void AddCharge(int); float GetBill(); };



LinkBack URL
About LinkBacks




CornedBee