中易网

c++问题 到底是哪里出错了

答案:3  悬赏:40  
解决时间 2021-01-30 10:59
#include"iostream"
using namespace std;
struct box{
char maker[40];#include"iostream"
using namespace std;
struct box{
char maker[40];
float height;
float width;
float length;
float volume;
}
void showstruct(struct box v);
int main()
{

struct box t1={ "hello123",
5,
4,
2,
40
};

showstruct(t1);
return 0;
}
void showstruct(struct box v)
{ using namespace std;
cout<<v.maker<<endl;
cout<<v.height<<endl;
cout<<v.width<<endl;
cout<<v.length<<endl;
cout<<v.volume<<endl;
}

float height;
float width;
float length;
float volume;
}
void showstruct(struct box v);
int main()
{

struct box t1={ "hello123",
5,
4,
2,
40
};

showstruct(t1);
return 0;
}
void showstruct(struct box v)
{ using namespace std;
cout<<v.maker<<endl;
cout<<v.height<<endl;
cout<<v.width<<endl;
cout<<v.length<<endl;
cout<<v.volume<<endl;
}
下面 是编译器编译的结果:
g++ 5.cpp
5.cpp:3:1: error: new types may not be defined in a return type
5.cpp:3:1: note: (perhaps a semicolon is missing after the definition of ‘box’)
5.cpp:10:29: error: two or more data types in declaration of ‘showstruct’
5.cpp: In function ‘int main()’:
5.cpp:21:14: error: ‘showstruct’ was not declared in this scope
#include"iostream"
using namespace std;
struct box{
char maker[40];
float height;
float width;
float length;
float volume;
}
void showstruct(struct box v);
int main()
{

struct box t1={ "hello123",
5,
4,
2,
40
};

showstruct(t1);
return 0;
}
void showstruct(struct box v)
{ using namespace std;
cout<<v.maker<<endl;
cout<<v.height<<endl;
cout<<v.width<<endl;
cout<<v.length<<endl;
cout<<v.volume<<endl;
}
最佳答案
你这段代码而言,具体的错误就是:
struct box{
char maker[40];
float height;
float width;
float length;
float volume;
}
这个结构体定义后边漏掉了一个分号";"
全部回答
#include"iostream" using namespace std; struct box{ char maker[40]; float height; float width; float length; float volume; }; void showstruct(struct box v); int main() { struct box t1={ "hello123", 5, 4, 2, 40 }; showstruct(t1); return 0; } void showstruct(struct box v) { using namespace std; cout<<v.maker<<endl; cout<<v.height<<endl; cout<<v.width<<endl; cout<<v.length<<endl; cout<<v.volume<<endl; } 定义结构体后加分号

错在这句

sout<<item1+item2<<endl;

把 sout 改成 cout

我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
请问怎样可以入读东莞横沥中心小学
补办结婚证可以查到老婆身份证信息吗
做一个男人最快乐的事是什么?
QQ里面把喜欢的明星添加为喜欢后,怎样进入他
除了帝国哪个大花天是多季的
比AKG420稍好的AKG耳机是哪个型号?450好吗?
女性肾虚会发胖原因是什么
三国中最厉害的武神是?
承德市哪里可以换轮胎
表现很吝啬的词语
新浪微博会员自动续费怎么关直接扣的银行卡的
高纬环球和高力国际这两家公司哪家好一点?
1976年8月21日是什么星座
小萍布艺地址在什么地方,我要处理点事
以前是做石雕的,然后吃到了石粉会怎样
推荐资讯
LED贴片射灯为什么亮几天灯珠就掉了呢? 灯珠
为什么生完宝宝之后,我的皮肤总是不能恢复呢
苹果没有备份手机短信删除了怎么恢复免费
日语重音标记中的三角是什么意思?
佳丽苑在什么地方啊,我要过去处理事情
福清酷动健身房游泳池营业时间
小米商城今天下单几天能到哈尔滨?
会计证考完中级职称还需要考什么职称
狙击精英v2怎么爆蛋
求一篇描写春天的清晨的作文。不许跑题,好的
投资一个小型汗蒸房大约多少资金
多力新出的那个鲜大师有人用过吗?感觉怎么样
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?