Open aLVINlEE9 opened 1 year ago
Fixed &operator++(void);
Fixed &operator--(void);
@aLVINlEE9 승슬님 지금 이 부분 말씀하시는거죠? 저는 내부에
Fixed &Fixed::operator++(void)
{
this->_fixedNum++;
return *this;
}
Fixed &Fixed::operator--(void)
{
this->_fixedNum--;
return *this;
}
이런 식으로 정의를 내렸는데
이게 *this
를 리턴하기때문에 레퍼런스가 아니여도 된다는 건가요?
넵넵
https://en.cppreference.com/w/cpp/language/operators
Although the canonical implementations of the prefix increment and decrement operators return by reference, as with any operator overload, the return type is user-defined; for example the overloads of these operators for [std::atomic]
canonical 구현은 return by reference인데, 사실상 user가 마음대로 할 수 있습니다. return by value로도 구현해도됩니다.