摘要:http://book.douban.com/people/ritchie/
阅读全文
摘要:c++标准程序库大量运用了pair 。 例如 map 和 multimap 容器的元素型别便是pair ,也就是一组键值/实值(key/value)。namespcae std{ template <class T1,class T2> struct pair { typedef T1 first_type; typedef t2 second_type; T1 first ; T2 second ; /* default constructor */ pair () ...
阅读全文
摘要:成员模板遵循与其他类成员相同的访问规则因为类成员模板CL 是类模板Queue 的一个私有成员所有只有Queue 的成员函数和友元friend 才能引用这个类成员模板的实例而函数成员模板assign()是一个公有成员所以它可以被整个程序使用。(c++ primer 第三版,P692) (C++标准模板库) #include <iostream>using namespace std;template <class T>class MyClass{ private : T value; public : template <class...
阅读全文