
196 ◾ Software Essentials
In a statically typed language like C++, C#, or Java, the only method that
may not be virtual is the constructor. Why? To allocate an object on the stack
in C++, the compiler must know the size, and therefore, the type of the object.
C# and Java follow the same programming language design as C++. However,
several design patterns mimic virtual construction (Gamma, 1995).
7.4 VIRTUAL FUNCTION TABLE
What code is generated by the compiler so that function resolution is
postponed until runtime? e solution is both elegant and ecient: a
jump table. When the compiler processes a dynamically bound func-
tion call, it gen ...