大神们,什么原因,怎么解决
#include <iostream>using namespace std;
struct{
int age;
double height;
}fq,zjl;
int main(){
fq.age = 22;
fq.height = 1.75;
zjl.age = 46;
zjl.height = 1.78;
cout<<fq.age<<","<<fq.height<<","<<zjl.age<<","<<zjl.height<<endl;
return 0;
}
编辑后显示: anonymous type with no linkage used to declare variable '<anonymous struct> fq' with linkage
该怎么处理? https://www.baidu.com/s?ie=UTF-8&wd=anonymous+type+with+no+linkage+used+to+declare+variable+%27%3Canonymous+struct%3E+fq%27+with+linkage&tn=02003390_hao_pg #include <iostream>
using namespace std;
struct astruct{
int age;
double height;
}fq,zjl;
int main(){
fq.age = 22;
fq.height = 1.75;
zjl.age = 46;
zjl.height = 1.78;
cout<<fq.age<<","<<fq.height<<","<<zjl.age<<","<<zjl.height<<endl;
return 0;
} 永恒的蓝色梦想 发表于 2020-5-7 21:17
谢谢,这是结构体的固定格式么?看的一个视频上的例子,并没有加structname{:10_243:} Knave@ 发表于 2020-5-7 21:51
谢谢,这是结构体的固定格式么?看的一个视频上的例子,并没有加structname
不一定,但是不给 structname 就会给警告 哦哦,好的,谢谢{:10_256:}
页:
[1]