当前位置: 答题翼 > 问答 > 求职面试 > 正文
目录: 标题| 题干| 答案| 搜索| 相关
问题

请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?class Fruit {


请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?

class Fruit

{

public:

Fruit()

{

weight = 2;

}

Fruit(int w)

{

weight = w;

}

int operator+(Fruit f)

{

return this->weight * f.weight;

}

private:

int weight;

};

Fruit aaa;

Fruit bbb(4);

int ccc = aaa + bbb;

请帮忙给出正确答案和分析,谢谢!

参考答案
答案整理中……
您可能感兴趣的试题
  • 请把下述代码加上异常处理。int MyWriteFile(CString strFileName, CString strText) { int nR

  • 请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?class Fruit {

  • {!rβθ#?》±} 《BKθ∫》……*=/ A.1 B.2 C.3 D.4

  • 下述关于代码设计的一组描述中,正确的是()A、代码的长度不能太短B、代码中可以有空格C、代码必须

  • 下列代码中 将引起一个编译错误的行是()。1)public class Test{2)int m n;3)public Test(){}4)pub

  • 下列代码中 将引起一个编译错误的行是( )。 1)public class Test{ 2)int m n; 3)public Test