[计算机科学经

4 class template partial specialization template

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: template 本身並不會被匯出(其定義仍然只在表頭檔 ㆗有效)。你也可以㆒如往常㆞隱式或顯式定義㆒些 inline 成員函式,但它們不能被匯出: C++ Templates - The Complete Guide 6.3 分離式模型(Separation Model) 69 export template <typename T> class MyClass { public: void memfun1(); // 會被匯出 void memfun2() { // 不會被匯出,因為它暗自成為 inline ... } void memfun3(); // 不會被匯出,因為它明確為 inline(見㆘方定義式) ... }; template <typename T> inline void MyClass<T>::memfun3 () { ... } 請注意,關鍵字 export 不能和關鍵字 inline 合用,而且關鍵字 export 應該總是寫在關鍵字 template 之前。以㆘程式碼是不合法的: template <typename T> class Invalid { public: export void wrong(T); }; export template <typename T> inline void Invalid<T>::wrong<T> { } // 錯誤:export 應該在 template 之前 // 錯誤:export 與 inline 合用...
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