Can the default value of a parameter be an expression?

  • No, it must be a constant value
  • No, it must be a string
  • Yes, but only for pointer parameters
  • Yes, it can be any valid expression
In C++, the default value of a function parameter can indeed be an expression. This expression can be any valid C++ expression, providing flexibility when setting default values. It's not limited to constant values and can include calculations or other expressions.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *