C++ | Function Overloading and Default Arguments | Question 5
Output of following program?
cout << fun(5);
(A) Compiler Error
Explanation: The statement “int fun(int=0, int=0)” is declaration of a function that takes two arguments with default values as 0 and 0.
The last statement is definition of fun().
When we make a call fun(5), x gets the value 5 and y gets 0. So the returned value is 5.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.