November 2019
Beginner to intermediate
674 pages
15h
English
We have inherited a problem-solver class called TDeepThough that we would like to pass to the FindTheAnswer function. This class is defined in the Adapter.Example.Inheritance unit as follows:
type TDeepThought = class public function FindTheAnswer: string; end;
We cannot use it directly, as it does not descend from the TProblemSolver class. Instead, we have to create an adapter. This adapter must inherit from the TProblemSolver class (otherwise, we would not be able to pass it to the FindTheAnswer function) and must somehow access an instance of a TDeepThought class that will do the real work. The following code fragment extracted from the Adapter.Example.Inheritance unit shows how this adapter is defined:
type TProblemAdapter ...
Read now
Unlock full access