Mat*_*att 6 c++ oop properties getter-setter
属性我指的是C#样式属性,带有getter和setter.
我很想知道他们为什么不是C++语言的一部分.我假设在编写规范时必须讨论这样的特性,因此认真考虑不将其包含在语言中.
这是一种实现: http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4031/Implementing-a-Property-in-C.htm
int i = 5,j;
PropTest test;
test.Count = i; //-- call the set method --
j= test.Count; //-- call the get method --
Run Code Online (Sandbox Code Playgroud)