64,648
社区成员
发帖
与我相关
我的任务
分享
class Node
{
Node *parent;
vector<Node> children;
Node(void)
{
this->parent = 0;
for (int i=0;i<4;++i)
this->children.push_back(Node(this)); ////这个this无法传递给儿子,这种该怎么初始化呢?
}
Node(Node *p)
{
this->parent = p;
}
}
class Node
{
Node *parent;
vector < Node* > children;
public:
Node(void)
{
this->parent = 0;
for (int i=0;i<4;++i)
this->children.push_back(new Node(this)); ////这个this无法传递给儿子,这种该怎么初始化呢?
}
Node(Node *p)
{
this->parent = p;
}
};
这样可以vector<Node*> children;
vector<shared_ptr<Node>> children;