Hi, I'm writing a program for an assignment at the moment requiring inheritance and dynamic objects.
Originally Posted by
Part of the program spec
Add a member attribute which is a pointer to a potential dynamic object of class Guest
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.
Heres my classes:
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();
};
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?