早教吧 育儿知识 作业答案 考试题库 百科 知识分享

errorC2360:initializationof'box1'isskippedby'case'label//定义盒子Box类,要求具有以下成员:可设置盒子形状;可计算盒子体积;可计算盒子的表面积.#include"iostream"usingnamespacestd;#include"string.h"//定

题目详情
error C2360:initialization of 'box1' is skipped by 'case' label
//定义盒子Box类,要求具有以下成员:可设置盒子形状;可计算盒子体积;可计算盒子的表面积.
#include"iostream"
using namespace std;
#include"string.h"
//定义Box类
class Box
{
private:
int height;
int width;
int length;
public:
Box(int h,int w,int len);//构造函数--长方体
Box(int len); //构造函数--正方体
int cvolume();
int zvolume();
int carea();
int zarea();
};
Box::Box (int h,int w,int len)
{
height=h;
width=w;
length=len;
}
Box::Box(int len)
{
length=len;
}
int Box::cvolume()
{
return(height*width*length);
}
int Box::zvolume()
{
return(length*length*length);
}
int Box::carea()
{
int s;
s=2*(length*width+width*height+length*height);
return(s);
}
int main()
{
int i,len,w,h;
couti;
switch(i)
{
case 1:
cout
▼优质解答
答案和解析
//定义盒子Box类,要求具有以下成员:可设置盒子形状;可计算盒子体积;可计算盒子的表面积.
#include"iostream"
using namespace std;
#include"string.h"
//定义Box类
class Box
{
private:
int height;
int width;
int length;
public:
Box(int h,int w,int len);//构造函数--长方体
Box(int len); //构造函数--正方体
int cvolume();
//int zvolume();
int carea();
//int zarea();
};
Box::Box (int h,int w,int len)
{
height=h;
width=w;
length=len;
};
Box::Box(int len)
{
length = len;
height = len;
width = len;
};
int Box::cvolume()
{
return (height*width*length);
};
//int Box::zvolume()
//{
// return (length*length*length);
//};
int Box::carea()
{
int s;
s=2*(length*width+width*height+length*height);
return (s);
};
int main()
{
int i,len,w,h;
couti;
switch(i)
{
case 1:
{
cout
看了errorC2360:init...的网友还看了以下: