记录详情

Compile Error

foo.cc: In member function 'Complex Complex::operator*(Complex&)':
foo.cc:21:7: warning: unused variable 'rr' [-Wunused-variable]
   21 |   int rr = c.re, ii = c.im;
      |       ^~
foo.cc:21:18: warning: unused variable 'ii' [-Wunused-variable]
   21 |   int rr = c.re, ii = c.im;
      |                  ^~
foo.cc: In function 'void test01()':
foo.cc:56:11: error: cannot bind non-const lvalue reference of type 'Complex&' to an rvalue of type 'Complex'
   56 |  C = c1+c2+c3;
      |      ~~~~~^~~
foo.cc:27:28: note:   initializing argument 1 of 'void Complex::operator=(Complex&)'
   27 |  void operator = (Complex &c)
      |                   ~~~~~~~~~^
foo.cc:59:12: error: cannot bind non-const lvalue reference of type 'Complex&' to an rvalue of type 'Complex'
   59 |  C1 = c1*c2*c3;
      |       ~~~~~^~~
foo.cc:27:28: note:   initializing argument 1 of 'void Complex::operator=(Complex&)'
   27 |  void operator = (Complex &c)
      |                   ~~~~~~~~~^
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1011 OO2-1 复数类的算术、赋值运算符的重载
比赛
2022春 面向对象程序设计方法的上机作业
语言
C++
递交时间
2022-04-30 20:34:16
评测时间
2022-04-30 21:04:02
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes