A C/C++ Function Call Puzzle
Consider the following program. Predict the output of it when compiled with C and C++ compilers.
void func() { /* definition */} int main() { func(); func(2); } |
chevron_right
filter_none
The above program compiles fine in C, but doesn’t compiler in C++.
In C++, func() is equivalent to func(void)
In C, func() is equivalent to func(…)
Refer this for details and this for more programs that compile in C, but not in C++.
This article is compiler by Rahul Mittalal. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Recommended Posts:
- Can we call an undeclared function in C++?
- Difference between Call by Value and Call by Reference
- pipe() System call
- Wait System Call in C
- Accept system call
- Is it possible to call constructor and destructor explicitly?
- Order of Constructor/ Destructor Call in C++
- dup() and dup2() Linux system call
- A C Puzzle
- A C/C++ Pointer Puzzle
- A Puzzle on C/C++ R-Value Expressions
- A nested loop puzzle
- A C Programming Language Puzzle
- Programming puzzle (Assign value without any control statement)
- Function Overloading vs Function Overriding in C++



