关于C++中的静态成员变量

来源:互联网 发布:ebsco数据库如何进入 编辑:程序博客网 时间:2024/04/28 14:19

这个东西每次都搞错:

////.h文件

class Node
{
public:
static Node* m_instance;
static Node * getInstance()
};
//.cpp

Node * Node::m_instance = NULL;

Node * getInstance()

{

if(Node::m_instance == NULL)

{

Node::m_instance = new Node()

}

return Node:m_instance;

}


//很简单,但是一直都没记住,哎。。。。。

0 0
原创粉丝点击