0

所以我一直在尝试实现与 C# 中相同类型的 get 和 set。但是有些事情对如何在 C++ 中声明变量产生了一些疑问。这是代码:

class foo {
    foo Getter() {
        return *this;
    }
    foo f; //this isn't allowed
    __declspec(property(get = Getter)) foo f2; // but this IS
};

这里到底发生了什么?

4

0 回答 0