详细的阐述有点长,我已经将我面临的问题分解为 3 个“回合”,所以请耐心等待......
对于第一轮,请考虑以下 C++ 代码,该代码没有错误并且行为符合预期:
#include <iostream>
using namespace std;
class rect{
float width;
float length;
public:
rect( float w = 5, float l=8 ) : width(w), length(l) {}
float area(){return width * length;}
};
class box{
rect base;
float height;
public:
box(rect a={2,7}, float c=9) : base(a), height(c){ } //round 1
//box(rect a={2}, float c=9) : base(a), height(c){ } //round 2 option 1
//box(rect a=(2), float c=9) : base(a), height(c){ } //round 2 option 2
//box(rect a=(2,7), float …Run Code Online (Sandbox Code Playgroud)