[计算机科学经

Iuedutveldhuipapers c templates the complete guide

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: A 都被省略了。 template <template <typename, typename = MyAllocator> class Container> class Adaptation { Container<int> storage; // 暗自(隱隱)等價於 Container<int, MyAllocator> ... }; 8.2.4 Default Template Arguments (預設的模板引數) 目前,只有 class template 的宣告式可以存在(擁有)default template arguments(將來 C++ 語言 可能會對此做出修改,見 13.3 節, p.207)。無論何種 template parameters 都可以有其預設引數, 當然它必須匹配(吻合)對應參。很明顯,預設引數不能相依於其自身參數,但可以相依於 在它之前宣告的參數: template <typename T, typename Allocator = allocator<T> > class List; 和函式的預設引數㆒樣,某個參數(譯註:不論是 call parameters 或 template parameters)帶有 預設引數的條件是:其後續所有參數也都有預設引數。 C++ Templates - The Complete Guide 8 104 基礎技術更深入(Fundamentals in Depth) 後續參數的預設引數通常寫在同㆒個 template 宣告式㆗,但也可以寫在該 template 更早的某個 宣告式㆗。例如: template <typename T1, typename T2, typename T3, typename T4 = char, typename T5 = char> class Quintuple; // OK template <typename T1, typename T2, typename T3 = char, typename T4, typename T5> class Quintuple; // OK:T4 和 T5 先前已有預設值 template <typename T1 = char, typename T2, typename...
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