O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.12. Virtual Constructors

You have seen the impact that virtual functions have on application designs. With dynamic binding, methods resolve at run time, easing maintenance when you add new classes and behaviors to inheritance hierarchies. This late-binding mechanism (virtual) applies to any class member function and destructor.

Not all class member functions are dynamically bound, however. A constructor, for example, may not be virtual. Why not? Recall that a constructor's primary task is to convert raw memory into initialized objects. A constructor must also build tables of virtual function pointers for dynamic binding (see Figure 11.14 on page 557). Since a “virtual” table for an object cannot exist before the compiler calls a class constructor, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required