64,651
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class A
{
public:
A(int x)
{
i = x;
}
int get()
{
return i;
}
private:
int i;
};
class B
{
public:
B(int a, int b, int c):x(a), width(b), length(c)
{
cout<<"长方体的面积为:"<<width.get()*length.get()<<endl;
}
private:
int x;
A width;
A length;
};
int main()
{
B b(10, 20, 30);
return 0;
}
class A
{
public:
A(){}
A(int x)
{
i=x;
}
void set(int x)
{
i = x;
}
int get()
{
return i;
}
private:
int i;
};