Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

VirtBase Class Reference

#include <Init.h>

List of all members.

Protected Member Functions

virtual void ctor ()=0
 VirtBase (const Init &init)

Friends

class Init

Classes

class  Init
 Inner class, used to dispatch virtual members. More...


Detailed Description

This is autenthic geniality by Carlo Pescio. The article (in Italian) is at http://www.eptacom.net/pubblicazioni/pub_it/nl_8.html

Shortly: this class is a workaround to the following problem:

struct Base
{
        Base(){
        f();
        }
        virtual void f();
};

struct Derived: public Base
{
        virtual void f();
}
if you create a Derived, you will find that the called virtual function won't be C::f, but B::f The following class shall be the virtual base class of every hierarcy like the previous one: if you correct the above code this way:
struct Base: public virtual VirtBase
{
        Base(const Init& i=Init()):VirtBase(i){
        }
        virtual void ctor(){
                f();
        }
        virtual void f();
};
struct Derived: public Base
{
        Derived(const Init& i=Init()):VirtBase(i){
        }
        virtual void f();
};
you will find that C::f() will be called


Constructor & Destructor Documentation

VirtBase::VirtBase const Init init  )  [inline, protected]
 


Member Function Documentation

virtual void VirtBase::ctor  )  [protected, pure virtual]
 


Friends And Related Function Documentation

friend class Init [friend]
 


The documentation for this class was generated from the following file:
Generated on Thu Jun 16 00:13:15 2005 for Netlib for Abuse! by  doxygen 1.4.3