C++/CLI:如何在 C++/CLI 中声明抽象(在 C# 中)类和方法?
以下 C# 代码在 C++/CLI 中的等价物是什么?
public abstract class SomeClass
{
public abstract String SomeMethod();
}
What is the equivalent of the following C# code in C++/CLI?
public abstract class SomeClass
{
public abstract String SomeMethod();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需稍微混合一下关键字即可得到正确的语法。 abstract 在 C# 中位于前面,但在 C++/CLI 中位于末尾。与 override 关键字相同,如今 C++11 兼容编译器也能识别该关键字,这些编译器希望将其放在函数声明的末尾处。就像传统 C++ 中的
= 0
一样来标记函数抽象:Just mix up the keywords a bit to arrive at the correct syntax. abstract goes in the front in C# but at the end in C++/CLI. Same as the override keyword, also recognized today by C++11 compliant compilers which expect it at the end of the function declaration. Like
= 0
does in traditional C++ to mark a function abstract:您使用
抽象
:You use
abstract
: