Semicolon in C++?

后端 未结 9 1643
心在旅途
心在旅途 2020-12-16 11:07

Is the \"missing semicolon\" error really required? Why not treat it as a warning?

When I compile this code

int f = 1
int h=2;

the

9条回答
  •  忘掉有多难
    2020-12-16 11:44

    There are many cases where a semicolon is needed.

    What if you had:

    int *y;
    int f = 1
    *y = 2;
    

    This would be parsed as

    int *y;
    int f = 1 * y = 2;
    

    So without the semicolons it is ambiguous.

提交回复
热议问题