Skip to content
Related Articles

Related Articles

Improve Article

Can we call an undeclared function in C++?

  • Difficulty Level : Easy
  • Last Updated : 09 Aug, 2018

Calling an undeclared function is poor style in C (See this) and illegal in C++. So is passing arguments to a function using a declaration that doesn’t list argument types:

If we save the below program in a .c file and compile it, it works without any error. But, if we save the same in a .cpp file, it doesn’t compile.

void f(); /* Argument list is not mentioned */
int main()
   f(2); /* Poor style in C, invalid in C++*/
   return 0;
void f(int x)
   printf("%d", x);


Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :