Thursday, November 26, 2009

abstract base class- pure virtual

IO_Field is an abstract base class and has some pure virtual functions, indicated by the
= 0; at the end.

virtual void display(void)const = 0;
virtual int edit(void) = 0;
virtual bool editable(void)const = 0;
virtual void set(const void *) = 0;
virtual void set(IO_Form* owner) = 0;

When functions are pure virtual, they should not have any other code (in the .cpp file). Also, when a class is an abstract base class with pure virtual functions, whatever classes that INHERIT the abstract base class (with pure virtual functions) MUST have code (usually in the .cpp) for those (pure virtual) functions (in the abstract base class).

No comments:

Post a Comment