View Single Post
Old 04-01-2005, 12:05 AM   #10 (permalink)
gab00n
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

Ok you have a high school student and a college student. They are both students but a college student is not a high school student and vice versa. I could ask both the same question and get a different response. That is like calling a function which both have in their class but you get a different response depending on who answers the question.

To be able to do this in our program we use Dynamic binding. Dynamic binding takes place when a member function is declared as virtual. When we ask the question, the ask function will be defined as virtual in our base class of type student. We don't know who will answer so we make sure that it can handle both answers. With Dynamic binding (late binding) the compiler will run through and determine who's version of ask to call as the program runs.

Dynamic binding is nice because you don't have to think up ten different print function names that do basically the same thing but are slightly different for each class.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline