Stuck in function and booleans

后端 未结 2 1561
余生分开走
余生分开走 2021-01-29 14:02

I have function called firstRun(), inside of it I have two defined booleans filesDeleted and dirsDeleted.

Also inside in function

2条回答
  •  囚心锁ツ
    2021-01-29 14:13

    Change your

    bool filesDeleted;
    bool dirsDeleted;
    

    to

    bool filesDeleted = false;
    bool dirsDeleted = false;
    

    These are local variables and they must be assinged before use them.

    From 5.1.7 Local variables

    A local variable is not automatically initialized and thus has no default value. For the purpose of definite assignment checking, a local variable is considered initially unassigned.

提交回复
热议问题