typeid and TypeInfo
Get introduced to the Object classes and the two properties: typeid and TypeInfo.
We'll cover the following...
Object
Classes that do not explicitly inherit any class, automatically inherit the Object
class.
By that definition, the topmost class in any class hierarchy inherits Object:
// Inherits Object indirectly
class StringInstrument : MusicalInstrument {
// ...
}
Since the topmost class inherits Object
, every class indirectly inherits Object
as well. In that sense, every class “is an” Object
.
Every class inherits the following member functions of Object
:
-
toString
: The string representation of the object. -
opEquals
: Equality comparison with another object. -
opCmp
: Sort order comparison with another object. ...