c++_primer_exercise_1609_1610_1611_1612_1613_1614_1615

来源:互联网 发布:真维斯官方旗舰店淘宝 编辑:程序博客网 时间:2024/06/07 21:45

Exercise 16.9:

function template --> Definition from which specific functions can be instantiated. A function template is defined using thetemplate keyword followed by a comma-separated list of one or more template parameters enclosed in < and > brackets, followed by a function definition.

class template --> Definition from which specific classes can be instantiated. Class templates are defined using the template keyword followed by a comma-separated list of one or more template parameters enclosed in < and > brackets, followed by a class definition.


Exercise 16.10:

Compiler process whereby the actual template argument(s) are used to generate a specific instance of the template in which the parameter(s) are replaced by the corresponding argument(s). Functions are instantiated automatically based on the argument used in a call. We must supply explicitly template arguments whenever we use a class template.


Exercise 16.11:

we must supply template argument when we use a class template type. inside the scope of the class template itself, we may use the name of the template without arguments. so in the definition of List, has something wrong with ListItem without argument.


Exercise 16.12:


Exercise 16.13:
// each instantiation of BlobPtr grants access to the equality operator instantiated with the same type
friend bool operator==<T> (const BlobPtr<T>&, const BlogPtr<T>&);

Exercise 16.14 16.15:

0 0
原创粉丝点击