Why compile error “Use of unassigned local variable”?

前端 未结 10 2187
说谎
说谎 2020-11-22 03:16

My code is the following

int tmpCnt;  
if (name == \"Dude\")  
   tmpCnt++;  

Why is there an error Use of unassigned local variabl

10条回答
  •  无人及你
    2020-11-22 04:14

    See this thread concerning uninitialized bools, but it should answer your question.

    Local variables are not initialized unless you call their constructors (new) or assign them a value.

提交回复
热议问题