+ 1
what's the error here??
6 Respostas
+ 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
+ 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
😊