Coder's Guild Mailing List

Re: Frank Hale: Virtual Functions continued...

Posted by Kspansel@xxx.xxx on 1999-09-14

In a message dated 9/14/99 1:55:11 AM Pacific Daylight Time, 
divine-bovine@xxxx.xxx writes:

> ChildTest ct;
>  ChildTest *pct = ct;
>  Test *pt = ct;
>  int ret = pt->SomeFunction();   //This one calls Test::SomeFunction();
>  int ret2 = pct->SomeFunction(); //This one calls
>  ChildTest::SomeFunction();
>  
>  if the function was virtual the pt->SomeFunction(); would call
>  ChildTest::SomeFunction();
>  
>  it makes it easy to have one pointer that can control different derived
>  objects that need slightly different functionality.  it's very useful in
>  some inctances like GUIs as Frank pointed out.

ok..I understand now.  I had misunderstood that part.  Thank you for clearing 
that up.  

Kory Spansel