记录详情

Compile Error

/in/foo.cc: In member function 'Complex& Complex::operator+(Complex&)':
/in/foo.cc:29:24: warning: reference to local variable 'ans' returned [-Wreturn-local-addr]
   29 |                 return ans;
      |                        ^~~
/in/foo.cc:28:25: note: declared here
   28 |                 Complex ans(*a+*obj.a,*b+*obj.b);
      |                         ^~~
/in/foo.cc: In member function 'Complex& Complex::operator*(Complex&)':
/in/foo.cc:33:52: error: no match for 'operator*' (operand type is 'Complex')
   33 |                 Complex ans(*a**obj.a-*b**obj.b,*a**obj.*b**obj.a);
      |                                                    ^~~~
/in/foo.cc:31:18: note: candidate: 'Complex& Complex::operator*(Complex&)'
   31 |         Complex& operator*(Complex &obj)
      |                  ^~~~~~~~
/in/foo.cc:31:18: note:   candidate expects 1 argument, 0 provided
/in/foo.cc:34:24: warning: reference to local variable 'ans' returned [-Wreturn-local-addr]
   34 |                 return ans;
      |                        ^~~
/in/foo.cc:33:25: note: declared here
   33 |                 Complex ans(*a**obj.a-*b**obj.b,*a**obj.*b**obj.a);
      |                         ^~~
/in/foo.cc: In destructor 'Complex::~Complex()':
/in/foo.cc:38:26: warning: right operand of comma operator has no effect [-Wunused-value]
   38 |                 delete a,b;
      |                          ^

信息

递交者
类型
自测
题目
P1011 OO2-1 复数类的算术、赋值运算符的重载
语言
C++
递交时间
2025-03-22 17:41:23
评测时间
2025-03-22 17:41:23
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes