0

Hi guys,

Ok, so I'm a bit stuck. I'm creating a program that has 3 classes. An object of one of the classes needs to be made up from 2 objects from one of the other classes.. and I can't figure out how to do it.

for example, if I have:

class Room{
private:
char name[];
int length;
// etc etc
public:
void some_function

and the I have..

class House{

..whos attributes are 2 'Rooms'. How would I do this?

If I try..

class House[
private:
Room 1;
Room 2;
// etc

..I get a compilation error telling me that 'Room' does not name a type!

I need to be able to send the parameters to the 'House' constructor, that will allow me to create 2 objects of type 'Room' within the class House.

Any help would be v.gratefully received!

Thanks in advance.

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Freaky_Chris
0

Hi - sorry, don't have the code to hand. This was a project i was working on in school. I just wanted to know if it was possible to create 2 objects of a class within the constructor of a separate class... ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.