Missing default argument - compiler error

前端 未结 5 1006
無奈伤痛
無奈伤痛 2021-01-31 15:17
void func ( string word = \"hello\", int b ) {

  // some jobs

}

in another function

 //calling 
 func ( \"\", 10 ) ;

When I have compiled it, compi

5条回答
  •  渐次进展
    2021-01-31 16:03

    The arguments with a default value have to come in the end of the argument list.

    So just change your function declaration to

    void func(int b, string word = "hello")
    

提交回复
热议问题