Early binding means that the address to be called when calling a function is statically known at compile time. Late binding means that the address of the function is calculated at runtime.
For a non-oo example something like this might explain it.
#include <iostream>
using namespace std;
int foo() {
return 100;
}
int bar() {
return 200;
}
int early_binding(bool b) {
switch(b) {
case true: return foo();
case false: return foo();
default:
throw exception("well this is unlikely");
}
}
int late_binding(int (*p)()) {
return p();
}
int main() {
cout << "early: " << early_binding(true) << endl;
cout << "late : " << late_binding(true ? foo : bar) << endl;
return 0;
}
For a OO-example, a virtual class member means that the lookup of the method address has to use the v-table, this leads to late binding (depending on the how the instance is "held");
#include <iostream>
using namespace std;
class base
{
public:
base() { }
virtual ~base() { }
virtual int foo() { return 100; }
};
class a : public base
{
public:
a() : base() { }
virtual int foo() { return 200; }
};
int main() {
base* x = new a();
cout << "Late: " << x->foo() << endl;
return 0;
}
Hope this helps,
Fredrik