记录详情

Compile Error

foo.cc: In function 'void Test1()':
foo.cc:54:24: error: cannot bind non-const lvalue reference of type 'Complex&' to an rvalue of type 'Complex'
   54 |  Complex snum(num1+num2+num3);
      |               ~~~~~~~~~^~~~~
foo.cc:11:19: note:   initializing argument 1 of 'Complex::Complex(Complex&)'
   11 |  Complex(Complex &c):real(c.real),image(c.image) { }
      |          ~~~~~~~~~^
foo.cc:55:24: error: cannot bind non-const lvalue reference of type 'Complex&' to an rvalue of type 'Complex'
   55 |  Complex mnum(num1*num2*num3);
      |               ~~~~~~~~~^~~~~
foo.cc:11:19: note:   initializing argument 1 of 'Complex::Complex(Complex&)'
   11 |  Complex(Complex &c):real(c.real),image(c.image) { }
      |          ~~~~~~~~~^
[Hydro](https://hydro.ac)提供评测服务

信息

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