void | SoloLearn: Learn to code for FREE!



Are these two same? //First one: void printSomething(int x=42) { cout<<x; } //Second one: void printSomething() { int x=42; cout<< x; }

9/5/2020 5:39:00 AM

Md. Tayebur Rahim

1 Answer

New Answer


In case first u passed a parameter which has its own default value If we call a function with parameter thn it changes the value of x and show the new value of x in output whereas in second case there is no parameter passed in function And value of x is always same as 42 hope u understand 😇