[计算机科学经

Pointer to pointer to char stdendl templatetypename

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 被具現於 某個精確位置(我是指目的檔, object file)有時很有用,而「自動具現化」不可能做到這㆒點(細 節請見第 10 章)。 stack.hpp: #ifndef STACK_HPP #define STACK_HPP #include <vector> template <typename T> class Stack { private: std::vector<T> elems; public: Stack(); void push(T const&); void pop(); T top() const; }; stackdef.hpp: #ifndef STACKDEF_HPP #define STACKDEF_HPP #include <stack.hpp> template <typename T> void Stack<T>::push (T const& elem) { elems.push_back(elem); } ... #endif #endif 圖 6.1 template 的宣告式與定義式分離 C++ Templates - The Complete Guide 6.2 顯式具現化(Explicit Instantiation) 67 6.2.2 結合置入式模型(Includsion model)和顯式具現化(Explicit Instantiation) 為了進㆒步討論究竟該使用「置入式模型」或使用「顯式具現化」,我們將 templates 的宣告式 和定義式分...
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