开发者

C++/CLI : How do I declare abstract (in C#) class and method in C++/CLI?

开发者 https://www.devze.com 2022-12-13 12:04 出处:网络
What is the equivalent of the following C# code in C++/CLI? public abstract class SomeClass { public abstract Str开发者_StackOverflow社区ing SomeMethod();

What is the equivalent of the following C# code in C++/CLI?

public abstract class SomeClass
{
    public abstract Str开发者_StackOverflow社区ing SomeMethod();
}


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:

public ref class SomeClass abstract {
public:
  virtual String^ SomeMethod() abstract;
};


You use abstract:

public ref class SomeClass abstract
{
    public:
        virtual System::String^ SomeMethod() = 0;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消