Semicolon after class declaration braces

前端 未结 7 868
忘了有多久
忘了有多久 2020-11-29 20:17

In C++ classes, why the semi-colon after the closing brace? I regularly forget it and get compiler errors, and hence lost time. Seems somewhat superfluous to me, which is un

7条回答
  •  死守一世寂寞
    2020-11-29 20:33

    It is needed after a struct for compatibility reasons, and how would you like this:

    struct MyStruct { ... };
    class  MyClass  { ... }    //inconsistency
    

提交回复
热议问题