我寫HAE下面的代碼:錯誤在C++模板片段
class Object
{
public:
Object()
{}
};
template <class T>
class Reg : public Object
{
T val,val_new;
public:
Reg(T initval)
{
super();
val=initval;
}
};
在代碼中的錯誤是
t.cpp: In constructor 'Reg<T>::Reg(T)':
Line 15: error: there are no arguments to 'super' that depend on a template parameter,
so a declaration of 'super' must be available
compilation terminated due to -Wfatal-errors.
我怎樣才能消除這個錯誤嗎?
什麼是「超級」?它在哪裏定義? (你通常用Java代碼嗎?) – Mat 2012-02-21 06:50:49
C++中沒有超類,因爲它允許多重繼承 – Anycorn 2012-02-21 06:53:37
VC++有'__super'關鍵字來訪問基類(如果沒有歧義的話)。其他編譯器也可能有類似的關鍵字。是的,那不是標準。 – Ajay 2012-02-21 08:31:08