c++ - 类内定义的名字是否可以以下划线开头?
黄舟
黄舟 2017-04-17 13:48:18
0
3
1074

《C++ Primer》第五版,中文版。42 页。
我记得有定义成员有下划线加名字的方式,为的是与构造函数的参数区分开,但是书上说函数之外不能以下划线开头。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
Ty80

Because it is in a class, it can start with an underscore followed by a lowercase letter, but it cannot start with a double underscore or an underscore followed by an uppercase letter. Please refer to here: http://stackoverflow.com/questions/228783/what-are- the-rules-about-using-an-underscore-in-a-c-identifier

小葫芦

As long as the defined member name complies with C++ specifications, it is OK.

The C++ standard has never stipulated that members outside functions cannot start with an underscore.

This may be useful to you https://www.zhihu.com/question/22419899

小葫芦

There is a way to write private attributes starting with an underscore.
Whether it can be written like this depends on the team's coding standards.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template