Temple of The Roguelike Forums
Development => Programming => Topic started by: Fenrir on July 27, 2010, 04:51:00 PM
-
Using C++ and PDCurses
I'm working on binary space partitioning for dungeon generation. Every BSP node should point to its parent, sibling, and children, but I can't do the following.
class BSP
{
private:
BSP * m_parent, m_sibling, m_childA, m_childB;
int m_depth;
int m_x, m_y, m_width, m_height;
public:
BSP(void);
~BSP(void);
const BSP * const parent() const;
const BSP * const sibling() const;
const BSP * const childA() const;
const BSP * const childB() const;
int depth() const;
void depth(int depth);
int x() const;
void x(int x);
int y() const;
void y(int y);
int width() const;
void width(int width);
int height() const;
void height(int height);
};
BSP is being defined, so I can't have member variables that are pointers to BSP objects. What should I do about it?
-
Yes you can. You just misused the syntax, it should be:
private:
BSP *m_parent, *m_sibling, *m_childA, *m_childB;
or less error prone:
private:
BSP* m_parent;
BSP* m_sibling;
BSP* m_childA;
BSP* m_childB;
-
Fenrir rolls his eyes and paws his face in disgust.
Oh. Thanks, aave.