-4
怎麼回事?這是它引用的功能。我試圖讓這個作爲一個拷貝構造函數引用類型的初始化無效?
template <class T>
const queue<Base>& queue<T>::operator=(const queue<Base> &q){
// Doesn't need to copy if they are the same object
if (this != &q){
delete [] data;
length = q.length;
capacity = q.capacity;
front = q.front;
data = new T[capacity];
for (int i = 0; i < capacity; i++){
data[i] = q.data[i];
}
}
return this;
}
當您作爲關於錯誤消息的問題時,習慣上指定哪條線產生錯誤。我們應該如何知道哪一行是第23行(或第190行)? – AnT 2014-09-24 23:44:59
爲什麼你需要一個賦值操作符?使用矢量而不是原始數組,默認的數組將自動工作。 – 2014-09-25 00:15:07
請注意,'operator ='應該返回一個*非const *引用。 – cdhowie 2014-09-26 03:11:54