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.
Loading...
Related Quiz
- In a system that processes user commands, you notice that the if-else chain for command processing has become excessively long and difficult to manage. Which refactorization strategy might be most effective?
- Unlike if-else, switch-case in C++ does not support _______ type for case values.
- The keyword _______ is used to grant a function or class access to the private and protected members of another class in C++.
- The concept of Streams in C++ was introduced in the standard with _______.
- When a function is called recursively for a purpose other than for a placeholder purpose, it's termed as ______ recursion.