C#-like properties in native C++?

后端 未结 11 1892
南笙
南笙 2020-11-29 04:46

In C# / .NET you can do something like this:

someThing.text = \"blah\";
String blah = someThing.text;

However, the above code does not actu

11条回答
  •  独厮守ぢ
    2020-11-29 05:12

    Yes but it's vendor specific. Microsoft has declspec(property). C++Builder's implementation is a bit more advanced (via vendor specific __property keyword) in that you could have indexed accessors (which can be of any types you wish).

    Also check this out (without relying on vendor specific keywords): http://www.codeproject.com/KB/cpp/cpp_property_indexer.aspx

提交回复
热议问题