Types of classes
An abstract class is one that is designed only as a parent class and from which child classes may be derived, and which is not itself suitable for instantiation. Abstract classes are often used to represent abstract concepts or entities. The incomplete features of the abstract class are then shared by a group of sibling sub-classes which add different variations of the missing pieces.
Abstract classes are superclasses which contain abstract methods and are defined such that subclasses are to extend them by implementing the methodss. The behaviors defined by such a class are "generic" and much of the class will be undefined and unimplemented. Before a class derived from an abstract class can be instantiated, it must implement particular methods for all the abstract methods of its parent classes.
Object-Based Programming
Some languages have objects, but no classes; In such "object-based languages", objects are not restricted to class structure.
C++ Examples
The first example shows how to define a C++ class; the example has no date, and performs no functions. It only contains the comment, "this is a class". The second example is of a somewhat more complex class definition.
Example 1
class example {
// this is a class
};
Example 2
- include
using std::string;
class InetMessage
{
string m_subject, m_to, m_from;
public:
InetMessage (const string& subject,
const string& to,
const string& from);
string subject () const;
string to () const;
string from () const;
};
See also
class, hierarchy