久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

“operator = must be a non-static member"是什么意思

What does quot;operator = must be a non-static memberquot; mean?(“operator = must be a non-static member是什么意思?意思?)
本文介紹了“operator = must be a non-static member"是什么意思?意思?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在創建一個雙鏈表,并重載了 operator= 以使列表中的另一個相等:

I'm in the process of creating a double-linked list, and have overloaded the operator= to make on list equal another:

template<class T>
void operator=(const list<T>& lst)
{
    clear();
    copy(lst);
    return;
}

但是當我嘗試編譯時出現此錯誤:

but I get this error when I try to compile:

container_def.h(74) : error C2801: 'operator =' must be a non-static member

另外,如果有幫助,第 74 行是定義的最后一行,帶有}".

Also, if it helps, line 74 is the last line of the definition, with the "}".

推薦答案

正如它所說的:運算符重載必須是成員函數.(在類中聲明)

Exactly what it says: operator overloads must be member functions. (declared inside the class)

template<class T>
void list<T>::operator=(const list<T>& rhs)
{
    ...
}

另外,從 = 返回 LHS 可能是個好主意,這樣你就可以鏈接它(比如 a = b = c) - 所以讓它list&list::operator=....

Also, it's probably a good idea to return the LHS from = so you can chain it (like a = b = c) - so make it list<T>& list<T>::operator=....

這篇關于“operator = must be a non-static member"是什么意思?意思?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 国产视频一区二区 | 亚洲天堂av在线 | 欧美中文一区 | 国产亚洲网站 | 国产精品www | 超碰免费在 | 99久久久国产精品 | 在线一区视频 | 婷婷成人在线 | 欧美性猛片aaaaaaa做受 | 亚洲天堂免费在线 | 免费一看一级毛片 | 国产成人一区在线 | 91精品久久 | 伊人久久大香线 | 久久爱黑人激情av摘花 | 观看av| 国产一在线 | 久久久久国产 | 免费精品在线视频 | 欧美精品一区免费 | 中文字幕日韩在线观看 | hsck成人网| 在线观看视频一区二区三区 | 欧美久久一区二区 | 亚洲成人播放器 | 亚洲第一av | av大全在线观看 | 国产激情一区二区三区 | www.精品国产 | 国产精品69av| 午夜电影日韩 | 久久激情视频 | 精品久久国产 | 一区二区三区国产精品 | 精品国产第一区二区三区 | 成人福利影院 | 久久久久国产 | 一区二区精品 | 亚洲一区二区不卡在线观看 | 国产精品视频97 |