當我在函數中返回指向引用類型的指針時,出現編譯器錯誤initial value of reference to non-const must be an lvalue。該功能是這樣 Testing& copy(Testing test)
{
x = test.x;
return this;
}
但是,當我改變this到*this,該錯誤消失。
可能重複: Difference between const declarations in C++ #include <iostream>
class Bar{};
void foo(const Bar x){} //l5
void foo(Bar x){} //l6
void foo(Bar const x){} //l7
////pointer functions
vo