Can we call an undeclared function in C++?
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.
#include<stdio.h> void f(); /* Argument list is not mentioned */ int main() { f(2); /* Poor style in C, invalid in C++*/ getchar(); return 0; } void f(int x) { printf("%d", x); } |
chevron_right
filter_none
Source: http://www2.research.att.com/~bs/bs_faq.html#C-is-subset
Recommended Posts:
- Difference between Call by Value and Call by Reference
- A C/C++ Function Call Puzzle
- pipe() System call
- Wait System Call in C
- Accept system call
- Is it possible to call constructor and destructor explicitly?
- dup() and dup2() Linux system call
- Order of Constructor/ Destructor Call in C++
- Function Overloading vs Function Overriding in C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- exp() function C++
- log() function in C++
- arc function in C
- fma() function in C++

