what's the error here?? | Sololearn: Learn to code for FREE!


what's the error here??



10/17/2021 8:14:56 AM


6 Answers

New Answer


You didn't have an empty constructor declared. complex res will not work. Use this instead: complex res(c1.real + c2.real, c1.img + c2.img); Also, you return a local reference and cause memory leak. In the declaration and the definition of sum return complex instead of complex&. BTW, sum() can can cause potential bug because it accept 2 lvalue arguments, Allowing you to modify the arguments when in reality, you just want to get sum and not intend to modify them. Consider use const complex& so you don't get a copy while exists no modification potential.


Martin Taylor ty


CarrieForle ty


Martin Taylor still giving same error.


Sometimes our device is giving blank space when we do it on moblile Which causes a problem like system. out. println which should be system.out.println 😊