Labs ICT
โญ Pro Login

Function Overloading

1 min read | C++ Tutorial
โญ

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Function Overloading

You can have multiple functions with the same name as long as their parameter lists differ in number, type, or both. The compiler picks the right one based on the arguments.

int add(int a, int b) {
  return a + b;
}

double add(double a, double b) {
  return a + b;
}

int add(int a, int b, int c) {
  return a + b + c;
}

The return type alone isn't enough to distinguish overloads โ€” the parameters must be different. This is called overload resolution.

Overloading makes your API consistent. Instead of addInt, addDouble, addThree, you just write add.

๐Ÿงช Quick Quiz

What is function overloading?