![](/img/trans.png)
[英]overloading operator << c++, I am trying to cout the element of class
[英]I am trying to use operator overloading in c++ but when I go to implement the function, it provides this error
我的函數原型是這樣的: const String operator+(const String&) const;
當我去實現這個函數時,我有這個: String String::operator+(const String&) {
}
這提供了一個錯誤,它顯示在我的 IDE 中修復它的唯一方法是更改我不能做的原型,這是在我的作業中給出的。 任何幫助表示贊賞。
原型的返回值是 const String 而實現中的返回值是 String (即沒有 const 限定符)。 一般來說,您應該提供更多代碼的詳細信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.