main()
{
f();
}
int f( int i, float fl)
{
printf("function");
}
Why does the above code runs successfully in 'C' and prints function
when it should report an error, as f () is being called before it is declared.
When it's running successfully in 'C', then why not in 'C++'. When running in c++ it's showing: error: 'f' was not declared in this scope
If it is because of something like the compiler assumes an undeclared function to return an int and accept an unspecified number of arguments, then why does it runs successfully for the function below too ( i.e. when returning the returning type to void instead of int ?
void f ( int i, float fl)
{
printf("function");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…