>[!important] > This page refers to Function / [[Method]] Overloading, for operators see [[Operator Overloading|here]] Overloading Functions & [[Method|Methods]] is the process of having a set of functions that have the *same name* but *different parameters*. This opposes C, where each function *must* have a unique name. The ability to overload a function’s name allows for names to be more readable and not contain [[Hungarian Notation]]-esque artifacts in the name. ```cpp void println(int x) { std::cout << x << std::endl; } void println(double x) { std::cout << x << std::endl; } int main() { println(10); // Through the type system, the compiler can figure out // the correct function to call. println(10.0); return 0; } ``` >[!warning] > Note that overload functions must have the same name and different *parameters*, meaning if two functions have the same name and parameters, but different *return types*, your code will not compile. >[!example] In C, to use the `sqrt` function on different types, you would need to use slightly different functions that muddy up the naming: >```c >float x = sqrtf(10.0f); >double y = sqrt(10.0); >long double z = sqrtl(10.0L); >``` > >In [[C++]], `std::sqrt` offers seperate overloads for each parameter type. > >```cpp >float x = std::sqrt(10.f); >double y = std::sqrt(10.); >long double y = std::sqrt(10.0L); >```