Design Patterns 3 : Adapter -- 变脸

来源:互联网 发布:js函数有返回值吗 编辑:程序博客网 时间:2024/06/11 01:05

Adapter is used to convert a existing interface into another interface, which could be use by the new system.

 

 

template <typename T>

class stack

{

public:

void push(const T& _value)

{

m_vectorT.push_back(_value);

}

 

void pop()

{

m_vectorT.pop_back();

}

 

T& top()

{

return m_vectorT.back();

}

 

private:

std::vector<T> m_vectorT;

};

 

 

Adapt the vector make it to behave like a stack. 

 

 

原创粉丝点击