Semicolon after class declaration braces

前端 未结 7 874
忘了有多久
忘了有多久 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:52

    I do not use such declarations

    class MyClass
    {
    .
    .
    .
    } MyInstance;
    

    But in this case I can understand why is semicolon there.
    Because it is like int a; - variable declaration.

    Probably for consistence as you can omit 'MyInstance' semicolon stays there.

提交回复
热议问题