我应该在头文件中的哪里指定我的类级静态常量?
class ABC
{
public:
enum A1
{
};
//Manager functions
ABC(int x )
{
m_x = x;
};
viirtual ~ABC();
protected:
int data;
private:
//Typedef
typedef std::pair(int, int) INT_PAIR;
typedef std::pair(int, int) INT_PAIR1;
...
//functions
void increment_x();
//Member data
int m_x;
... whole lot of other data
}
我应该在哪里声明一个私有静态常量变量,比如这个类声明(ABC.h)中的版本号?
static const std::string version;
它到底适合哪里?它不是真正的成员数据,因为它是静态的。(不是每个对象)
编辑 - 1:
这些变量是否有特定的优先级?他们是从一开始就开始(就在 ABC 类之后的第一个左大括号之后?还是就在我的片段中的 private 关键字之后?(或)是在 typedef 之后?
当然,我会在我的 abc.cpp 文件中提到 const std::string version = "10";
编辑2:我期待像卢卡斯提到的那样的答案。(请提供有效的推理)
在我下面提到的类声明中,静态变量应该放在哪里?
请不要提供提及 decl 需要在 .h 文件中并在 .cpp 文件中定义的答案。——我已经知道了。