Lisa has a function that calculates the area of a rectangle. She wants to modify the function such that if only one argument is provided, it calculates the area of a square. Which C++ feature can help her achieve this?

  • Default Arguments
  • Function Overloading
  • Operator Overloading
  • Type Conversion
Lisa can use Default Arguments in C++ to modify her function. By assigning a default value to one of the function's parameters, she can make it so that if only one argument is provided, it calculates the area of a square by using the default value as the second argument.
Add your answer
Loading...

Leave a comment

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