Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Learn New Techniques for Employing Templates in C++

You might be surprised to find out that templates and inheritance interact in interesting ways. However, it turns out that some techniques make use of so-called ''parameterized inheritance.'' This sample chapter describes a few of these techniques.


advertisement
he idea of templates in C++ is more than ten years old. C++ templates were already documented in 1990 in the Annotated C++ Reference Manual and they had been described before that in more specialized publications. However, well over a decade later there was a dearth of literature that concentrates on the fundamental concepts and advanced techniques of this fascinating, complex, and powerful C++ feature. C++ Templates: The Complete Guide was written to address this issue.

The two authors approached the task with different backgrounds and with different intentions. David Vandevoorde, an experienced compiler implementer and member of the C++ Standard Committee Core Language Working Group, was interested in an exact and detailed description of all the power (and problems) of templates. Nico Josuttis, an "ordinary" application programmer and member of the C++ Standard Committee Library Working Group, was interested in understanding all the techniques of templates in a way that he could use and benefit from them.

As a consequence, you will see both conceptual introductions with day-to-day examples and detailed descriptions of the exact behavior of templates. Starting from the basic principles of templates and working up to the "art of template programming," you will discover (or rediscover) techniques such as static polymorphism, policy classes, metaprogramming, and expression templates. You will also gain a deeper understanding of the C++ standard library, in which almost all code involves templates.

Chapter 16: "Templates and Inheritance" discusses named template arguments, empty base class optimization (EBCO), layout principles, members as base classes, and more .

Download the PDF of Chapter 16: "Templates and Inheritance"

Reproduced from C++ Templates: The Complete Guide by permission of Addison Wesley. ISBN 0201734842, copyright 2003. All rights reserved.



   
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap