问题详情

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

请问下述代码中: 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;

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

参考答案
答案整理中……
您可能感兴趣的试题