c++程序出错了,帮忙诊断!

我编了一个图书管理小程序,有些模块还未编完。先编好的出现了小问题,帮忙诊断!程序如下:

#include<iostream>
#include<fstream>
using namespace std
class shu
{
private:
char shu_name[10];
char cbs_name[20];
float shu_money;
int shu_num;
public:
void getdata()
{
cout<<"输入书名:";
cin>>shu_name>>endl;
cout<<"输入书的编号:";
cin>>shu_num>>endl;
cout<<"输入书的出版社名称:";
cin>>cbs_name>>endl;
cout<<"输入书的价格";
cin>>shu_money>>endl;
return;
}
void displaydata()
{
cout<<setiosflag(ios::left)<<shu_num<<setw(4)<<shu_name<<setw(4)<<cbs_name<<setw(4)<<shu_money<<endl;
return;
}
};
void input_data()
{ ofstream indata;
indata.open("tushu.dat");
shu s;
s.getdata();
indata.write((char*)&s,sizeof(s));
indata.close();
return;
}
void disp_data()
{ ifstream dispdata(tushu.dat);
shu s;
s.display_data();
dispdata.read((char*)&s,sizeof(s));
dispdata.close();
return;
}

int main()
{int x;
do
{cout<<"请选择:1、图书录入 2、显示图书信息"<<endl;
cin>>x;
swith(x)
{case 1:input_data();break;
case 2:disp_data();break;
}
}
while(x==1||x==2);
return 0;
}

编译后提示错误:
tushu.cpp
E:\c++练习程序\图书查询\tushu.cpp(5) : error C2143: syntax error : missing ';' before '<class-head>'
E:\c++练习程序\图书查询\tushu.cpp(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

tushu.obj - 2 error(s), 0 warning(s)
不行呀,改了还是错误不少:
tushu.cpp
E:\c++练习程序\图书查询\tushu.cpp(15) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
E:\c++练习程序\图书查询\tushu.cpp(26) : error C2065: 'setiosflags' : undeclared identifier
E:\c++练习程序\图书查询\tushu.cpp(26) : error C2065: 'setw' : undeclared identifier
E:\c++练习程序\图书查询\tushu.cpp(40) : error C2065: 'tushu' : undeclared identifier
E:\c++练习程序\图书查询\tushu.cpp(40) : error C2228: left of '.dat' must have class/struct/union type

woodmaster,又是你!
namespace std;要加冒号!!!!!!
你的冒号哪???
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-11-12
是分号
第2个回答  2009-11-12
using namespace std后面要加分号~
你要连这个错误也看8出来~~你能写出来这个代码?
相似回答
大家正在搜