Friday, June 08, 2007

Abstract Class

An abstract class is a class that is only meant to be inherited from. Objects cannot be created from generic classes.

To make a class abstract one of the virtual methods is made abstract by assigning it a value of zero. To make a concrete class the virtual method must be implemented in the inheriting class.

class A
{
virtual void AbstractMethod() = 0;
// The '= 0' makes the method a pure virtual
// function.
// The pure virtual function makes the class
// abstract.
};

class B: public A
{
void AbstractMethod();
};

void B::AbstactMethod()
{
}

No comments: