what's the error here?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
17th Oct 2021, 8:14 AM
Brat__
Brat__ - avatar
5 Answers
+ 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.
17th Oct 2021, 12:56 PM
你知道規則,我也是
你知道規則,我也是 - avatar
17th Oct 2021, 4:31 PM
Brat__
Brat__ - avatar
17th Oct 2021, 4:31 PM
Brat__
Brat__ - avatar
+ 1
Martin Taylor still giving same error.
17th Oct 2021, 9:48 AM
Brat__
Brat__ - avatar
+ 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 😊
19th Oct 2021, 2:07 AM
Maneek Kaur