John is writing a function to concatenate two strings. He wants the function to add a space between the strings by default but also wants to give the user the option to specify their own separator. Which feature of C++ can help him?
- Default Arguments
- Function Overloading
- Function Templates
- Operator Overloading
John can use Default Arguments in C++ for his string concatenation function. By providing a default value for the separator parameter, he ensures that if the user doesn't specify a separator, a space is added by default. However, users can still customize the separator if they want.
Loading...
Related Quiz
- What is the main function in a C++ program responsible for?
- A member function that is used to initialize the class members is known as a _______.
- How would you declare a variable pi that holds the value of pi up to several decimal places?
- Consider a scenario where a loop is expected to run based on an external condition (like an external input). Which loop is most appropriate for this scenario?
- The ternary operator, represented as ? :, can serve as a shorthand for a simple if-else statement.