我来自 .NET 世界,并且是编写 C++ 的新手。我只是想知道在命名局部变量和结构成员时首选的命名约定是什么。
例如,我继承的遗留代码有很多:
struct MyStruct
{
TCHAR szMyChar[STRING_SIZE];
bool bMyBool;
unsigned long ulMyLong;
void* pMyPointer;
MyObject** ppMyObjects;
}
来自 C# 背景的我很震惊地看到带有匈牙利符号的变量(我第一次看到 pp 前缀时就忍不住笑了)。
我宁愿以这种方式命名我的变量(尽管我不确定首字母大写是否是一个好的约定。我见过其他方式(见下面的链接)):
struct MyStruct
{
TCHAR MyChar[STRING_SIZE];
bool MyBool;
unsigned long MyLong;
void* MyPointer;
MyObject** MyObjects;
}
我的问题:这(前一种方式)是否仍然是在 C++ 中命名变量的首选方式?
参考:
http://geosoft.no/development/cppstyle.html
http://www.syntext.com/books/syntext-cpp-conventions.htm
http://ootips.org/hungarian-notation.html
谢谢!