[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppBaseClass
Every base class must have a virtual destructor.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppBaseClass
(C++) Base class
A class that is used to inherit from. The inherited class is called the derived class. If the base class cannot be instanciated it is called an Abstract Base Class (or ABC).Every base class must have a virtual destructor.
struct Base
{
int mX;
virtual ~Base() {} //Virtual destructor
};
struct Derived: public Base
{
int mY;
//Does not have a virtual destructor. This class is not meant to derive from
};
int main()
{
Derived d;
d.mY = 0;
d.mX = 0; //mX is inherited from Base
}
'Base class' links
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
