본문 바로가기

IT책/Effective c++

항목 10 : 대입연산자는 *this의 참조자를 반환하게 하자

class test
{

	test& operator =(const test& param){return *this;}

	test& operator -=(const test& param){return *this;}

	test& operator +=(const test& param){return *this;}

	test& operator *=(const test& param){return *this;}

	test& operator /=(const test& param){return *this;}

}

대입연산자에는 return *this의 참조자를 반환하자 

다른거 써도 딱히 뭐 잘못된다는건 아니지만 

관례라고한다 그냥 지켜주자

 

이것만은 잊지 말자!

*대입 연산자는 *this의 참조자를 반환하도록 만들어야한다