星野竜一中文漫画:被一个简单的C++问题困扰

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 22:13:25
#include<iostream.h>
#include<iomanip.h>
struct time
{
int year;
int month;
int day;
};
void main()
{
time T;
cout<<"please input the time"<<endl;
cin>>T.year>>T.month>>T.day>>endl;
cout<<"now,let me show the time"<<endl;
cout<<setw(7)<<T.year<<"."<<setw(7)<<T.month<<"."<<setw(7)<<T.day<<endl;
}
编译失败
-------------------Configuration: 成功2 - Win32 Debug--------------------
Compiling...
成功2.cpp
E:\xingc\成功2.cpp(13) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class ostream &(__cdecl *)(class ostream &)' (or there is no acceptable conversion)
执行 cl.exe 时出错.

成功2.exe - 1 error(s), 0 warning(s)
但不知道是哪里错了啊,希望高手帮一下忙啊!!

cin>>T.year>>T.month>>T.day>>endl;

cin没有endl这个操纵符,去掉

应该 是:
cin>>T.year>>T.month>>T.day>>endl;
有问题吧,去掉>>endl,改为:
cin>>T.year>>T.month>>T.day;