首先參數化類一個可以通過一個參數化類作爲參數傳遞給另一個將由另一
template<typename T>
class elements
{
protected:
int e,f;
public:
elements(){}
elements(int ee):e(ee){}
const elements& operator=(const elements& other)
{
e = other.e; return *this;
}
};
基類
template<typename T>
class list
{
protected:
T item;
};
最後,在爭用的類派生
template<typename T>
class row:public list<elements<T> >
{
public:
row(int a)
{
item;
}
};
如果參數被指定爲int,list等,那麼程序運行,否則我不斷收到錯誤 'item'未在此範圍內聲明,
我似乎無法開始工作,並希望有人能幫助我理解它是如何工作的。
感謝
是什麼'element'作爲一個模板的意義呢?它不使用'T' – user463035818
請發佈一個完整的程序來演示你所得到的錯誤。 – xaxxon
@ m.s。好決定。 – xaxxon