Skip to Content
Navigating C++ and Object-Oriented Design
book

Navigating C++ and Object-Oriented Design

by Paul Anderson, Gail Anderson
October 1997
Intermediate to advanced
800 pages
20h 48m
English
Pearson
Content preview from Navigating C++ and Object-Oriented Design

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, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exploring C++20: The Programmer's Introduction to C++

Exploring C++20: The Programmer's Introduction to C++

Ray Lischner

Publisher Resources

ISBN: 0135327482Purchase book