C++/CLI 有哪些属性?
我在 C++ 代码中看到了术语 property
。我认为它与 C++/CLI 有关。
到底是什么?
I saw in the term property
in C++ code. I think it's connected to C++/CLI.
What is it exactly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它确实与 C++/CLI 有关(非托管 C++ 并没有真正的属性概念)。
摘自本文:http://www.codeproject.com/KB/mcpp/CppCliProperties。另
请参阅 MSDN< /a> C++/CLI 中的属性。
示例代码:
It was indeed connected to C++/CLI (unmanaged C++ doesn't really have a notion of properties).
Taken from this article: http://www.codeproject.com/KB/mcpp/CppCliProperties.aspx
Also see MSDN on properties in C++/CLI.
Sample code:
是的,这确实是 Microsoft 版本的托管 C++ 代码或 C++/CLI。现在不仅还得写Get &设置方法,但您还需要将其定义为属性。 我会说,尽管我讨厌额外键入该属性的“只读”和“只写”版本,但它非常整洁。
但在非托管 c++ 中是不必要的!
例如,您可以在类中编写(将执行完全相同的操作!):
“const”确保“GET”是只读的,并且集合是清晰的。无需定义属性或添加 String^ 与 std::string 的混淆......
Yep indeed this is Microsoft's version of managed c++ code or C++/CLI. Now not only do you still have to write Get & Set Methods but you also need to define it as a property. I will say as much as I hate the extra typing the 'Read Only' and 'Write Only' versions of the property is pretty neat.
But unnecessary in un-managed c++!!!
For instance you could write in a class (will do exactly the same thing!):
The 'const' made sure it 'GET' was read only, and the set was clear. No need to define a property or add the confusion of String^ vs. std::string....