我有一个简单的对象,其中包含一些 [公共] 数据。
我想保持我的界面干净,所以我不想为可公开访问的变量的名称或我的函数参数的名称预先/后置任何东西。
也就是说,我最终做了这样的事情:
template<typename T> struct Foo
{
explicit Foo(T x) : x(x) // This [i.e., x(x)] seems to be doing the "Right Thing", but is this well defined?
{/* ^
No pre-/post- fixing.
*/
}
T x; // No pre-/post- fixing.
};
重申一下:我要问的是这是否是明确定义的行为。不知道我应该或不应该这样做......
谢谢。