健康,快乐,勇敢的宁帅!!

努力、努力、再努力! 没有什么能阻止我对知识的渴望。

 

"C++Templates The Complete Guide"读书笔记----Chapter 7

Basic Template Terminology
1. "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

Declarations become definitions when the details of their structure are made known or, in the case of variables, when storage space must be allocated.
class C{}// definition(and declaration) of class C
void f(int p)// defini
   std::cout<< p << std::endl;
}


extern int v = 1;  // an initializer makes this a definition for v

int w;   // global variable declaration not preceded by extern are also definitions
By extension, the declaration of a class template or function template is called a definition if it has a body, Hence,
template <typename T>
void func(T);
is a declaration that is not a definition, whereas
template <typename T>
class S{};
is in fact a definition

posted on 2006-12-03 15:02 ningfangli 阅读(109) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

公告

Dict.CN 在线词典, 英语学习, 在线翻译

常用链接

留言簿(4)

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜