in C++ by (15.1k points)
0 like 0 dislike
204 views

I want to set function with static class object parameter set as default. How I can to set default value for function/method parameter as static created class object in C++?


  • c++ function default argument object
  • c++ function default argument value for class object
  • c++ function default value for argument of complex type

1 Answer

0 like 0 dislike
by (15.1k points)

To set default value for function parameter as static created class object, use next syntax:

int someFunc(int a, FooCls fooObj = FooCls(), double bar = 5.73);

or with transfer several parameters to overloaded class constructor:

int someFunc(int a, FooCls fooObj = FooCls(5, true, 1.8f), double bar = 5.73);

Please log in or register to answer this question.