7.8b vs2010不知道搞毛,居然爆了一推出错。 但是在Dev c++运行完成没问题,暂时还不知道为什么。 已经搞清楚了错误所在。 原因是:std名称空间已经有了exp这个关键词的存在! 将exp改为Exp或者 using namespace std改为 using std::cout; using std::cin;
#include
using namespace std;
const int Seasons=4;
const char *season[Seasons]={“Spring”,”Summer”,”Fall”,”Winter”};
struct exp
{
double ex[Seasons];
};
void fill(exp &ex);
void show(const exp &ex);
int main()
{
exp ex;
fill(ex);
show(ex);
cin.get();
system(“pause”);
return 0;
}
void fill(exp &ex)
{
for(int i=0;i<Seasons;i++)
{
cout<<”\nEnter “<<*(season+i)<<” expenses:”;
cin>>ex.ex[i];
}
cout<<”Enter end!”;
}
void show(const exp &ex)
{
cout<<”\nshow start!”<<endl;
for(int i=0;i<Seasons;i++)
{
cout<<”The “<<*(season+i)<<” expenses is “<<ex.ex[i]<<endl;
}
cout<<”show endl”<<endl;
}
—————————————————————————————————————————————————— //写的错误或者不好的地方请多多指导,可以在下面留言或者给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。 转载请注明出处:https://www.royalchen.com/ author:royalchen Email:royalchen@royalchen.com ———————————————————————————————————————————————————
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/cprimerplus第六版课后编程题答案78b/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!