Hanging else problem?

后端 未结 4 1194
轮回少年
轮回少年 2021-01-14 03:12

What is the \"hanging else\" problem? (Is that the right name?)

Following a C++ coding standard (forgot which one) I always use brackets (block) with control structu

4条回答
  •  半阙折子戏
    2021-01-14 03:19

    Ambiguous else.

    Some info here: http://theory.stanford.edu/~amitp/yapps/yapps-doc/node3.html

    But the classic example is:

    if a then
      if b then
         x = 1;
      else 
         y = 1;
    

    vs.

    if a then
      if b then
         x = 1;
    else 
      y = 1;
    

提交回复
热议问题