Why prototype is required even without any class declaration?

前端 未结 3 1923
故里飘歌
故里飘歌 2021-01-14 00:55

If I just do it: Ex1:

#include 

int main()
{
    //try to call doSomething function
    doSomething();
}

void doSomething(         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 01:49

    Because the compiler hasn't seen doSomething before it's used.

    Either you must prototype it, or define it first, so that the compiler knows how to analyze the usage of it.

提交回复
热议问题