[求助]这个为什么错了?
求助]这个为什么错了?我用的是VC++2005
#include <iostream>
using namespace std;
struct inflatable
{
char name[20];
float volume;
double price;
};
int main()
{
inflatable guest=
{
"Glorious Gloria",
?1.88,
29.99
};
inflatable pal=
{
"Audacious Arthur",
?3.12,
32.99
};
cout<<"Expand your guest list with "<<guest.name<<" and "<<pal.name<<"!\n";
cout<<"You can have both for $"<<guest.price+pal.price<<"!\n";
return 0;
}
警告 1 warning C4305: “初始化”: 从“double”到“float”截断 e:\microsoft visual studio 2005 简体中文专业版\vc++2005\项目\4.11\4.11\structur.cpp 14
警告 2 warning C4305: “初始化”: 从“double”到“float”截断 e:\microsoft visual studio 2005 简体中文专业版\vc++2005\项目\4.11\4.11\structur.cpp 20
请各位大哥指点指点!!
#include <iostream>
using namespace std;
struct inflatable
{
char name[20];
float volume;
double price;
};
int main()
{
inflatable pal[2]=
{
{"Glorious Gloria",1.88,29.99},
{"Audacious Arthur",3.12,32.99}
};
cout<<"Expand your guest list with "<<pal[0].name<<" and "<<pal[1].name<<"!\n";
cout<<"You can have both for $"<<pal[0].price+pal[1].price<<"!\n";
return 0;
}
这个和上面出来的结果一样,哪个更好些?
我用的是VC++2005
请各位大哥指点指点!!
#include <iostream>
using namespace std;
struct inflatable
{
char name[20];
float volume;
double price;
};
int main()
{
inflatable pal[2]=
{
{"Glorious Gloria",1.88,29.99},
{"Audacious Arthur",3.12,32.99}
};
cout<<"Expand your guest list with "<<pal[0].name<<" and "<<pal[1].name<<"!\n";
cout<<"You can have both for $"<<pal[0].price+pal[1].price<<"!\n";
return 0;
}
这个和上面出来的结果一样,哪个更好些?不过2个程序都出现2个警告!!警告如下:
警告 1 warning C4305: “初始化”: 从“double”到“float”截断 e:\microsoft visual studio 2005 简体中文专业版\vc++2005\项目\4.11-\4.11-\-.cpp 13
警告 2 warning C4305: “初始化”: 从“double”到“float”截断 e:\microsoft visual studio 2005 简体中文专业版\vc++2005\项目\4.11-\4.11-\-.cpp 14
[此贴子已经被作者于2007-5-23 18:36:48编辑过]