qq_35018969 2016-07-02 08:55 采纳率: 100%
浏览 1034
已采纳

C++大神们帮我看看错误

 #include"iostream.h"
#include"fstream.h"
#include"string.h"
#include"conio.h"
#include"windows.h"



using namespace std
string id
class Book
{
protected:
string no;
string pricing;

char writer[20];
char title[10];
char house;
Book *next;
public:
Book(string pricing,string id,char * writer,char * title,char * house)
{
strcpy(this->writer,writer)
strcpy(this->title,title)
strcpy(this->house,house)
this->pricing=pricing;
this->no=id;
}
friend class Manage;
};
class Manage
{
private:
Book*Book;
public:
Manage()

(book=0;Load(););}
~Manage()
{
Book *p;
p=book;
while(p)
{p=p->next;delete book; book=p;}
book=0;
}
void Find(char writer[20]);
void Find(string id)
void Add();
void Query();
void Load();
void Save();
void Output(Book * P)
{
cout<<"\t\t编号:"<<p->no<<endl;
cout<<"\t\t作者:"<<p->writer<<endl;
cout<<"\t\t书名:"<<p->title<<endl;
cout<<"\t\t价格:"<<p->pricing<<endl;
cout<<"\t\t出版社:"<<p->house<<endl;
cout<<endl;
}
};
void Manage::Add()
{
system('cls')
Book *p,*p2;
string pricing,no;
char writer[20],title[10],house;
char c;
cout<<"\n* * 新增书籍**\n";
cout<<" 输入编号:\t";
cin>>no;
cout<<endl;
{
Book *p1;
p1=book;
while(p1)
{
if(p1->no=no)
break;
eles
p1=p1->next;
}
if(p1!=NUll)
{
cout<<" 该书编已存在,是否修改该图书信息(Y/N)"<<endl;
cin>>c;
if(toupper(c)= ='Y')
{
cout<<"该学生信息为: "<<endl;
Find(no);
cout<<endl;
Modify(no);
return;
}
else
return;
}
}
cout<<" 输入价格:\t";
cin>>pricing;

cout<<"输入作者:\t";
cin>>writer;

cout<<"输入书名:\t";
cin>>title;
cout<<"输入出版社:\t";
cin>>house;
cout<<endl;
p=new Book(no,writer,pricing,title,house);
p->next=0;
if(book)
{
p2=book;
while(p2->next)
p2=p2->next;
p2->next=p;
}
else
book=p;
system("cls");
cout<<"\t\t ****添加成功****\n"<<endl;
cout<<"是否继续添加(Y/N)"<<endl;
cin>>c;
if(toupper(c)= ='Y')
{Add();return;}
else
return;
}
void Manage::Save()
{
ofstream fBook("Book.txt",ios::out);
char c;
cout<<"\n保存数据,是否继续?[Y/N]:";
cin>>c;
if(toupper(c)!='Y')
return;
Book *p=book;
while(p)
{
fBook<<p->no<<" "<<p->pricing<<" "<<p->writer<<" "<<p->title<<" "<<p->house<<endl;
p=p->next;
}
fBook.close()
cout<<"\n保存成功**\n";
system("pause");
}
void Mange::Load()
{
ifstream fBook;
Book *p=book;
string no,pricing;
char writer[20],title[10],house;
fBook.open("book.txt",ios::in);
fBook>>no>>pricing>>writer>>title>>house;
while(fBook.good())
{
p=new Book(no,pricing,writer,title,house);
p->next=0;
if(book)
{
Book * p2;
p2=book;
while(p2->next)
p2=p2->next;
p2->next=p;
}
else
book=p;
fBook>>no>>pricing>>writer>>title>>house;
}
fBook.close();
}
void Manage::Query()
{
char c;
string id;
char writer[20];
do{
cout<<"1.按编号找2.按作者找3.退出查找"<<endl;
cin>>c;
cout<<endl;
switch(c)
{
case'1':{
cout<<"输入编号id:";
cin>>id;
cout<<endl;
Find(id);
};
break;
case'2':{
cout<<"输入作者:";
cin>>writer;
cout<<endl;
Find(writer)'
};break;
case'3':break;
default: cout<<"输入有误 请重新输入"!!!\\n"<<endl;
}
}while(c!='1'&&c!='2'&&c!='3'&&c!='4');
cout<<"\t\t\t ****查找成功****\n"<<endl;
cout<<"是否继续查找(Y/N)"<<endl;
cin>>c;
if(toupper(c)= ='Y')
{Query();return;}
else
return;
system("pause");
}
int main(void)
{
Manage m;
int c;
do
{
cout<<"============================================"<<endl;
cout<<"**\t  1.新增书籍  \t**"<<endl;
cout<<"**\t  2.查询书籍  \t**"<<endl;
cout<<"**\t  3.保存数据  \t**"<<endl;
cout<<"============================================"<<endl;
cout<<"0-退出\t请选择(1-8):";
cin>>c;
switch(c)
{
case 1:m.Add();break;
case 2:{
system("cls");
m.Query();
   };
break;
case 3:m.Save();
break;
default: break;
}
}
while(c!=0);
char s;
cout<<"\n**是否要保存你的所有操作(Y/N):"<<endl;
cin>>s;
if(toupper(s)= ='Y')
m.Save();
return 0;
}
  • 写回答

4条回答 默认 最新

  • 小灸舞 2016-07-02 09:08
    关注

    错误一大坨,你这个代码网上拷来的?
    1.using namespace std后面要加分号
    2.string id后面也要分号
    3.protected后面的分号你是中文字符
    4.strcpy后面也不加分号?
    ........
    PS:根据编译器提示的错误,自己一个个改

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题