   C++ virtual functions
  If I have three classes, base, derived, and twiceDerived: class base{virtual void func() {printf("base");}};class derived: public base{void func() {printf("derived");}};class twiceDerived: public derived{void func() {printf("twiceDerived");}};If I do this: derived *p = new twiceDerived;p->func();The twiceDerived::func() is called even though derived::func() is non-virtual. I thought that if I declared derived::func() as not being virtual, that a call to ((derived*)p)->func() would be a call to derived::func().   
  In C++, "once virtual, always virtual". derived::func is virtual even if not marked as such; there is no way to un-virtualize it.Virtual functions don't work by working down the hierarchy one step at a time. The function to call is looked up directly according to the runtime type of the pointed-at object. It doesn't matter whether you declare 'p' as a base* or a derived* for this purpose.   ;  If you declare a function virtual in the base class all derived class versions are virtual as well.BTW, you should never attempt to redefine an inherited non-virtual function.  In the book Effective C++ by Scott Meyers, there is an example of why this is bad.  Read this.Edit: wrong link before sorry.   