转换器和设置器的参数的命名约定 [英] Naming convention for params of ctors and setters
本文介绍了转换器和设置器的参数的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于那些没有像 m_foo
或 foo _
这样的特殊符号的成员变量命名的人,
For those of you who name you member variables with no special notation like m_foo
or foo_
, how do you name parameters to your ctors and setters?
到目前为止,我尝试过的一些选项...
Some options I've tried so far...
Obj(int foo) : foo(foo) { }
void set_foo(int foo) { this->foo = foo; }
Obj(int _foo) : foo(_foo) { }
void set_foo(int _foo) { foo = _foo; }
Obj(int a_foo) : foo(a_foo) { } // a for "argument"
void set_foo(int a_foo) { foo = a_foo; }
Obj(int init_foo) : foo(init_foo) { }
void set_foo(int new_foo) { foo = new_foo; }
推荐答案
我使用foo_,因为它不会与实现特定的函数名称和关键字冲突。
I'm using foo_, it's better than _foo since it won't conflict with implementation specific function names and keywords.
这篇关于转换器和设置器的参数的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文