A blog about learning C and C++

C++ function overloads

January 27, 2025, by Slobodan Dmitrovic

If coming from a C background, one of the novelties we encounter in C++ is called function overloads.

Function overloading

In C++, we can have multiple functions with the same name but with:

  • different number of arguments or
  • different types of arguments

These groups of functions are called function overloads or overloaded functions. Example:

void myfunction(char arg);

void myfunction(int arg);

void myfunction(int argx, double argd);

void myfunction(char argc, const std::string& args);

Overloading different kinds of functions

We can overload both:

  • The free-standing functions
  • Class member functions

For example, inside C++ classes, we can have multiple constructor overloads and other member function overloads.

Differences between C and C++ - Function overloads

We also have a dedicated training course called "C++ for C Developers." For more info, contact us at contact@cppsrc.com.

Download the Brochure