연산자 오버로딩 질문이 있습니다.
글쓴이: impactlife / 작성시간: 토, 2013/07/27 - 5:49오후
class Complex{
private:
double real;
double image;
public:
Complex(){;}
Complex(double r, double i):real(r), image(i){;}
void OutComplex(){
printf("%.2f+%.2f\n", real, image);
}
const Complex* operator ++();
};
const Complex* Complex::operator++(){
this->real++;
this->image++;
return this;
}
void main(){
Complex c1(1.1, 2.2);
c1.OutComplex();
c1++;
c1.OutComplex();
++c1;
c1.OutComplex();
}
이 소스에서 c1++ 과 ++c1 의 연산을 다르게 하고 싶은데요 operator++ 이건 선언이 가능한데 ++operator 이런 선언은 불가능 하네요
++operator 와 같이 전위증가시키는 연산자를 만드려면 어떻게 선언해야 하나요?
Forums:
자문자답
그냥 인자에 int 를 적어주면 되는군요.
조금만 검색하면 될것을 괜히 질문했네요.
죄송합니다.
댓글 달기