c++g++default-arguments

"default argument missing for parameter" compiler error


void func ( string word = "hello", int b ) {
    // some jobs
}

in another function

//calling 
func ( "", 10 ) ;

When I compile, it emits this error:

default argument missing for parameter

I want to use that function like func ( 10 ) or func ( "hi" ).

How can I fix it without changing anything, such as setting int b = 0?


Solution

  • You can't have non-default parameters after your default parameters begin. Put another way, how would you specify a value for b leaving word to the default of "hello" ?