Robert wants to write a function that can either accept two parameters or three. What feature of C++ should he use to achieve this?

  • Function Overloading
  • Function Pointers
  • Template Functions
  • Inheritance
Robert should use "Function Overloading" to write a function that can accept either two or three parameters. Function overloading allows him to define multiple functions with the same name in the same scope but with different parameter lists. The compiler will then determine which function to call based on the number or types of arguments passed to it. This flexibility enables Robert to create a single function name with different parameter options.
Add your answer
Loading...

Leave a comment

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