Object-Oriented Programming
Polymorphism
Polymorphism is the ability of objects, inherited from a common
base or parent class, to respond differently to the same message.
This is done by de
fi
ning different implementations of the same
method name within the individual child class de
fi
nitions. For
example: A DogArray object, "DogArray OurDogs[2];" refers to
two element objects of class Dog, the base class:
• King, of class Doberman, is a derived or child class of Dog.
• Fi
fi
, of class Minipoodle, is a derived or child class of Dog.
If, in a program, OurDogs[n]->Bark( ) is called in a loop, then:
• In iteration one ([1]), method King::Bark( ) is called.
• In iteration two ([2]), method Fi
fi
::Bark( ) is called.
King’s bark does not sound like Fi
fi
’s bark because each Bark( )
call is a separately de
fi
ned method within its child object
de
fi
nition. The virtual parent class (Dog) method Bark( ) is
de
fi
ned in the class de
fi
nition of Dog.
Object
Implementation
Benefits
The bene
fi
ts of creating RTR solutions with objects include the
following:
• Each major RTR concept is represented by its own individual
foundation class.
• Simple methods within RTR classes transform features of
RTR for streamlined solutions.
• Major classes include Get and Set methods for changing
transaction states.
• Default handling code is provided for all Messages and
Events, where appropriate.
• You do not need to provide handling code for all messages
and events.
• The sending and receiving of data is abstracted to a higher
level with transaction controller and data classes.
• No buffers and links coding is needed.
• Internal RTR information is accessible without a need to
know RTR internals.
2–10 Architectural Concepts