Why is the semicolon not required but allowed at the end of a class definition?

前端 未结 5 1428
忘了有多久
忘了有多久 2020-12-18 18:57

I\'m trying to shift from C++ to Java.

What I wonder is, in C++, after a class definition, a semicolon (;) is required, but in Java it isn\'t.

T

5条回答
  •  轮回少年
    2020-12-18 19:37

    I think this is a followed style which inherites from C:

    struct A
    { 
        unsigned a;
        unsigned b;
    };
    

    Or you can use:

    struct A
    { 
        unsigned a;
        unsigned b;
    }A1,A2;
    

提交回复
热议问题