A "class" in Ada denotes a family of types.
For tagged types, the type T'Class denotes the type T and all its
So if I have this hierarchy:
type T is tagged private;
type U is new T with private;
type W is new U with private;
type V is new T with private;
An object of "class-wide" type T'Class can be any of the "specific" types T,
U, V, or W.
An object of class-wide type U'Class can be any of the specific types U
This distinction is nice, because it allows you to see explicitly when
you have a specific type (T), or a type and any of its descents
(T'Class). It makes it obvious that procedures like:
procedure Print (Stack : in Stack_Type'Class);
are intended to work for Stack_Type and any type that derives from
Print is not a primitive operation of type Stack_Type, and therefore
doesn't get inherited during derivations from Stack_Type. There is one
and only one Print operation, and it works for any kind of stack (that
is, those that derive from stack, i.e. in Stack_Type'Class).
But if I see this:
function Is_Full (Stack : in Bounded_Stack) return Boolean;
then I know that Is_Full is only intended to take an object of
(specific) type Bounded_Stack. A stack that derives from Bounded_Stack
would indeed inherit operation Is_Full.
T'Class is a "class-wide" type, which denotes a family of "specific"
types: type T, and any type that derives from T.