rokoder

Archive for March, 2012

C++ Templates, not so generic

by on Mar.19, 2012, under Programming

Lets start with basic ideology of .h and .cpp files. When building libraries, the idea is to share only your header files and not your implementation (mean .cpp files). This is also the basics OOP’s encapsulation, abstraction etc, to hide the implementation details.

Now templates in C++ violates this encapsulation principle, bcoz C++ is a compiled language. And compiler generates all the needed (generic) code during compilation (it is different from Java as in Java this code can be generated in Java Run Time during execution and not at compilation. As Java compiled .class files contains enough info to generate a specific implementation later). Now to adhere to OOP we end up with fragile templates which are not 100% generic in nature.

Now there are two ways to implement templates.
(continue reading…)

Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...

Archives

All entries, chronologically...