?? books.cpp
字號(hào):
#include "books.h"
#include <fstream>
namespace jixia
{
Books::Books()
{
v.clear();
}
void Books::Open(char fname[])
{ ifstream fin(fname);
while( !fin.eof() )
{ int x1; string x2,x3,x4;
fin>>x1>>x2>>x3>>x4;
Book b(x1,x2,x3,x4);
v.push_back(b);
}
}
void Books::Save(char fname[])
{
ofstream fout;fout.open(fname);
for(int i=0;i<v.size();i++)
fout<<v[i].ID<<" "<<v[i].Name<<" "<<v[i].Author<<" "<<v[i].Price<<endl;
}
ostream& operator<<(ostream &o,Books &bs)
{
for(int i=0;i<bs.v.size();i++)
o<<bs.v[i]<<endl;
return o;
}
void Books::Search(int ID)
{
for(int i=0;i<v.size();i++)
if(v[i].ID==ID)
cout<<v[i];
}
void Books::Append(int ID1,string Name1,string Author1,string Price1)
{ Book s(ID1,Name1,Author1,Price1);
v.push_back(s);
}
void Books::Delete(int ID)
{
for(int i=0; i<v.size()-1; i++)
if(v[i].ID==ID)
v.erase(v.begin()+i);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -