<div>#include <iostream></div> <div>using namespace std;</div> <div><br></div> <div>class Complex {</div> <div>private:</div> <div><span style="white-space:pre;"> </span>double real;</div> <div><span style="white-space:pre;"> </span>double image;</div> <div>public:</div> <div><span style="white-space:pre;"> </span>Complex() {};</div> <div><span style="white-space:pre;"> </span>Complex(double n, double m){</div> <div><span style="white-space:pre;"> </span>real = n;</div> <div><span style="white-space:pre;"> </span>image = m;</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>Complex operator =(Complex c);</div> <div><span style="white-space:pre;"> </span>void PrintComplex(){</div> <div><span style="white-space:pre;"> </span>cout << real << "+" << "j" << image << endl;</div> <div><span style="white-space:pre;"> </span>}</div> <div>};</div> <div><br></div> <div>Complex Complex::operator =(Complex c){</div> <div><span style="white-space:pre;"> </span>Complex tmp;</div> <div><span style="white-space:pre;"> </span>tmp.real = c.real;</div> <div><span style="white-space:pre;"> </span>tmp.image = c.image;</div> <div><span style="white-space:pre;"> </span>return tmp;</div> <div>}</div> <div><br></div> <div>int main() {</div> <div><span style="white-space:pre;"> </span>Complex c1(1.2, 2.4), c2(1.0, 0.2);</div> <div><br></div> <div> c2 = c1;</div> <div><span style="white-space:pre;"> </span>c2.PrintComplex();</div> <div>}</div> <div><br></div> <div><span style="font-size:9pt;">c1에 있는 값을 c2에 덮어씌우고 싶습니다만..... </span></div> <div><span style="font-size:9pt;">c2객체를 프린트함수에 넣으면 </span><span style="font-size:9pt;">1.2+j2.4 가 아닌 원래의 1.0+j0.2 즉, 원래의 c2값이 튀어나옵니다.</span></div> <div><span style="font-size:9pt;"><br></span></div> <div>operater = 구현 부분이 잘못된것같은데 도와주세요 ㅠㅠㅠㅠㅠㅠㅠㅠㅠ</div>