用下面的執行STL容器名單,我試圖回答my question:與替代類指針
class wlist
{
private:
std::list<void*> m_list;
public:
unsigned int size() { return m_list.size(); }
bool empty() { return m_list.empty(); }
void pop_back() { m_list.pop_back(); }
void pop_front() { m_list.pop_front(); }
};
class qwertyWrap : public wlist
{
public:
int getNumber() { ptr->getNumber(); }
void setNumber(int x) { ptr->setNumber(x); }
private:
qwerty* ptr;
};
class qwerty
{
public:
int getNumber();
void setNumber(int x);
};
class asdf
{
public:
int getElement();
void setElement(int x);
private:
/* Question */
/* Can the following declaration be substituted by qwertyWrap keyboard ??? */
list<qwerty*> keyboard; or qwertyWrap keyboard;
};
問: 我可以代替「列表的鍵盤」代替「qwertyWrap鍵盤」類ASDF並實現與STL列表相同的功能?
如果您不使用它,則可以使用int替換列表。你在「鍵盤」上實際嘗試使用什麼方法/概念? –
BatchyX
2011-03-04 09:47:22
@BatchyX - 我打算使用qwertyWrap鍵盤使用類wlist和類qwerty的方法。 – codebin 2011-03-04 19:20:54