我觉得看这个例子就应该明白了 A simple property would be: struct Foo { int data() { return m_data; } // read property int data(int value) { return m_data = value; } // write property private: int m_data; } To use it: int test() { Foo f; f.data = 3; // same as f.data(3); return f.data + 3; // same as return f.data() + 3; }
D语言对property的支持
最新推荐文章于 2024-01-29 00:18:40 发布