[计算机科学经

C addison wesley reading ma 2000 stroustrupdne bjarne

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: plate<typename T, typename A = MyAllocator> class Container> class Adaptation { Container<int> storage; // 暗自(隱寓)等價於 Container<int, MyAllocator> ... }; C++ Templates - The Complete Guide 8.2 Template Parameter(模板參數) 103 在 template template parameters ㆗, template parameter 的名稱只能被用於 template template parameter 的其他參數宣告㆗。這㆒點可以㆘面例子來解釋: template <template<typename T, T*> class Buf> class Lexer { static char storage[5]; Buf<char, &Lexer<Buf>::storage[0]> buf; ... }; template <template<typename T> class List> class Node { static T* storage; // ERROR:這裡不能使用 template template parameters 的參數 T ... }; 通常 template template parameter ㆗ template parameters 名稱並不會在其他㆞方被用到,因此, 未被用到的 template parameters 可以不具名。例如㆖頁的 Adaptation template 可被宣告為: // 譯註:原先(㆖頁最㆘)的兩個參數名稱 T 和...
View Full Document

This note was uploaded on 08/25/2012 for the course EECS 101 taught by Professor Wre during the Fall '12 term at Beacon FL.

Ask a homework question - tutors are online