Saturday, January 18, 2014

one definition rule templates

one definition rule in c++ : templates tutorial ccplusplus.com
The C++ language definition places some constraints on the redeclaration of various entities. The totality of these constraints is known as the one-definition rule or ODR. The details of this rule are quite complex and span a large variety of situations. Later posts illustrate the various resulting facets in each applicable context, and. For now, it suffices to remember the following ODR basics:
  • Noninline functions and member functions, as well as global variables and static data members should be defined only once across the whole program.
  • Class types (including structs and unions) and inline functions should be defined at most once per translation unit, and all these definitions should be identical.
A translation unit is what results from preprocessing a source file; that is, it includes the contents named by #include directives.

In the remainder of this book, linkable entity means one of the following: a noninline function or member function, a global variable or a static data member, including any such things generated from a template.








-----------------------------------------------------------------
See Also:
-----------------------------------------------------------------

-----------------------------------------------------------------

No comments:

Post a Comment