"C++Templates The Complete Guide"讀書筆記----Chapter 7
Basic Template Terminology1. "Class Template" or "Template Class"?
class template: the class is a template.
template class: a synonym(同義詞) for class template; to refer to classes generated from templates(由模板產生(實例化)的類). to refer to classes with a name that is a template-id.
Because of this imprecision, template class is avoided in this book.
2. Instantiation and specialzation
Instantiation: 實例化. The process of creating a regular class, function, or member function from a template by substituting actual values for its arguments is called template instantiation.
Specialzation:特例,在Chapter 3中有描述
3. Declarations vs Definitions
declaration is a C++ construct that introduces or reintroduceds a name into? a C++ scope.
class?C;?//?a?declaration?of?C?as?a?class
void?f(int?p);?//?a?declaration?of?f()?as?a?function?and?p?as?a?named?parameter
extern?int?v;?//?a?declaration?of?v?as?a?variable
void?f(int?p);?//?a?declaration?of?f()?as?a?function?and?p?as?a?named?parameter
extern?int?v;?//?a?declaration?of?v?as?a?variable
Declarations become definitions when the details of their structure are made known or, in the case of variables, when storage space must be allocated.












template?<typename?T>
void?func(T);
is a declaration that is not a definition, whereasvoid?func(T);
template?<typename?T>
class?S{};
is in fact a definition
class?S{};
posted on 2006-12-03 15:02 ningfangli 閱讀(112) 評論(0) 編輯 收藏 引用