在其定义中的类变量?

在其定义中的类变量?

问题描述:

这可能是一个愚蠢的问题。我试图做一个文本泥。我需要每个Room类包含其他房间类,人们可以参考时,试图移动他们或从他们获取信息。但是,我不能这样做,因为我显然不能在其定义中声明一个类。那么,我该怎么做呢?这是我的意思,当我说我不能这样做:

This is probably a dumb question. I am trying to make a text-mud. I need each Room class to contain other Room classes that one can refer to when trying to move to them or get information from them. However, I can not do that because I obviously can not declare a class within its definition. So, how do I do this? Here's what I mean when I state I can not do it:

class Room {
    public:
        Room NorthRoom;
        Room EastRoom;
        Room SouthRoom;
        Room WestRoom;
};


不可能有 Room 成员变量。

class Room {
    public:
        Room* NorthRoom;
        Room* EastRoom;
        Room* SouthRoom;
        Room* WestRoom;
};