【发布时间】:2010-11-01 01:35:25
【问题描述】:
在 C++ 中,我想定义一些将在类中使用的字符串,但这些值将在所有实例中通用。在 C 语言中,我会使用 #defines。这是一个尝试:
#include <string>
class AskBase {
public:
AskBase(){}
private:
static std::string const c_REQ_ROOT = "^Z";
static std::string const c_REQ_PREVIOUS = "^";
static std::string const c_REQ_VERSION = "?v";
static std::string const c_REQ_HELP = "?";
static std::string const c_HELP_MSG = " ? - Help\n ?v - Version\n ^^ - Root\n ^ - Previous\n ^Z - Exit";
};
int main(){AskBase a,b;}
如果需要 C++0x 是可以接受的。
【问题讨论】: