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

+1

what's the error here??

https://code.sololearn.com/ckUR7NKtnl8x/?ref=app

c++

10/17/2021 8:14:56 AM

Iffat

6 Answers

New Answer

+3

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.

+2

There are spaces between your object and members/methods. It should read object.member but you have object. member This is what happens when you try to write code on a phone with auto correct turned on.

+2

Martin Taylor ty

+2

CarrieForle ty

+1

Martin Taylor still giving same error.

+1

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 😊