int var = 1; void main() { int i = i; }

前端 未结 4 1946
攒了一身酷
攒了一身酷 2020-12-03 23:48

This is an interview question that I had:

int var = 1;
void main()
{
    int i = i;
}

What is the value of i after assignment?

4条回答
  •  囚心锁ツ
    2020-12-04 00:25

    I had the same interview question and I can confirm that it was indeed int var = 1;

    Which implies that that does make some difference. I would run the code but I'm not at my PC right now.

    I agree that questions like these are daft for interviews. By analogy it's like if someone is interviewing for a job as a chef and the question is "If you fed someone a spoonful of e coli, drizzled with typhoid, how sick would they get?". You're unlikely to ever need that knowledge in the job.

提交回复
热议问题