The meaning of underscore in front of C++ variables

Adding an underscore or not adding an underline in front of a C++ variable will not affect the definition of the variable. It is just a matter of style. I prefer to add an underscore in front of member variables or private member variables. To indicate that the variable is an attribute of a certain class.

such as:

int size;

int getsize()

{

    return size;

}

但是大多数人都不喜欢,觉得麻烦,就用了如下风格:

int _size;

int size()

{

    return _size;

}

 

 

Undertake programming in Matlab, Python and C++, machine learning, computer vision theory implementation and guidance, both undergraduate and master's degrees, salted fish trading, professional answers please go to know, please contact QQ number 757160542 for details, if you are the one.

 

 

Guess you like

Origin blog.csdn.net/weixin_36670529/article/details/115053507