There is a difference between function overloading and function overriding.
You can overload a function or method by declaring or defining multiple functions or methods with the same name in the same scope, but with different signatures:
Code:
int foo(void);
int foo(int);
int foo(double);
void foo(int, int);
The compiler figures out which of these to call based on the number and types of parameters; if you write foo(), the first version will be called. If you write foo(3.14159), then the third version will be called.
You can override a method by inheriting it from a base class, then changing the implementation in the child class:
Code:
class base {
public:
void foo() { cout << "in base::foo" << endl; }
};
class derived : public base {
public:
void foo() { cout << "in derived::foo" << endl; }
};
The definition of foo in derived overrides the definition in base. The method signature (return type and parameters) is the same between the parent and child class, but the implementation in the child class is different, and they occur in different scopes.
Hopefully that made sense.