An object has both fields with data and functions (aka methods) which it
can perform. A PDP Unit as an object might have the fields
activation
and netinput
, and some functions like
ComputeActivation()
and ClearNetInput()
. In C++ this might
look like:
class Unit { float activation; // this is a member holding activation float netinput; // this is a member holding net input virtual void ComputeActivation(); // this is a function void ClearNetInput(); // this is a function }
C++ also provides the mechanisms for object inheritance in which a new
object can be defined as having the same fields and functions as its
"parent" object with the addition of a few fields and/or functions of
its own. In PDP++ the BpUnit object class inherits from the parent
Unit class and adds fields such as bias weight
and a BackProp
version of ComputeActivation
. In C++ this might look like:
class BpUnit : public Unit { float biasweight; // a new member in addition to others void ComputeActivation(); // redefining this function void ClearBiasWeight(); // adding a new function }
By overloading the ComputeActivation function the BpUnit redefines the way in which the activation is computed. Since it doesn't overload the ClearNetInput function, the BPUnit clears its net input in the exact same way as the standard unit would. The new function ClearBiasWeight exists only on the BpUnit and is not available on the base Unit class. Through this type of class inheritance, PDP++ provides a hierarchical class structure for its objects.
For a slightly more detailed treatment of some of the basic ideas in OOP and C++, see section 7.3.4 Features of C++ for C Programmers.