开发者

C++ CLI Missing ';' before '}'

I am learning C++/CLI and attempting to build an Interop component 开发者_如何学编程for my C# project. I'm not sure what this error means or how to resolve it? Any ideas?

#pragma once

using namespace System;

namespace Firewall {

    public ref class Firewall
    {
        void StartFirewall(){};
    }
}


Unlike C#, C++ requires a semicolon after a type definition.

public ref class Firewall
{
    void StartFirewall(){} // doesn't require semicolon here
}; // needs semicolon here.

In C#, you can actually have semicolons after type definitions (not recommended though) and that will be ignored. It is there for the sake of consistency with C++ syntax.


There is no need to have the ; in the place you currently have it. Instead place it after the closing } of the class Firewall.

public ref class Firewall
{
    void StartFirewall(){}
};
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜