Apologies if this basic question has already been answered. What would I put inside the brackets of print() so that the first parameter is left to the default value but the following parameters are given new values of 1 and 2? I know I can literally put 0 in there but is there a way for it go to a default?
#include<iostream>
using namespace std;
void printer(int a=0, int b=0, int c=0){
cout << a << endl;
cout << b << endl;
cout << c << endl;
}
int main(){
//leave a=0 and replace both b and c
printer(/*?*/,1,2);
return 0;
}
You cannot do that, it's not allowed. Only right most parameters could be omitted.
Default parameter list is right associative. So its not possible to ommit first parameter list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With