我試圖創建一個堆棧,但即時通訊接收錯誤與重載my =操作符。 堆棧是類型模板。繼承人代碼重載操作員=錯誤
template <typename T>
T& ::stack& operator =(const stack& other)
{
if (this == &other) return *this;
copy(other.stack1[0], other.stack1[other.size], stack1[0]);
return *this;
}
任何幫助將不勝感激。由於
請張貼您遇到的錯誤。現在,我會說,返回'* this'不正確,因爲'this'已經是一個指針了。 – 2014-10-05 06:38:26
什麼是T&:: stack&'? – chris 2014-10-05 06:39:35
@JaviV但是操作員不會,也不應該返回一個指針。 – juanchopanza 2014-10-05 06:40:21