VOOZH about

URL: https://www.geeksforgeeks.org/cpp/interesting-facts-default-arguments-c/

⇱ Some Interesting facts about default arguments in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Some Interesting facts about default arguments in C++

Last Updated : 23 Jul, 2025
Predict the output of following C++ programs. 1) The above program looks correct at first glance but will fail in compilation. If function uses default arguments then default arguments can't be written in both function declaration & definition. It should only be in declaration, not in definition. The following program is now correct. 2)
If you closely observe function prototype then it looks like an error but it isn't actually. Variable names can be omitted in default arguments.
Comment
Article Tags: