# include & lt; Cstring>
# include & lt; Fstream>
using namespace std;
The class Date {
Public:
Int year;//in
Int the month;//
Int day;//day
Date () {year=2020; The month=1; Day=1; }//three are constructor
The Date (int y, int m, int d) : the year (y), month (m), day (d) {}
The Date (const Date& B) {year=b.y ear; The month=b.m onth. Day=b.d ay; }
To Date () {}
};
Class Base0//base class
{
Public:
Base0 () {}
Base0 (char num [8], char nam [10], int y, int m, int d, float sco) : birth (y, m, d)
{strcpy (no, num);
Strcpy (name, nam);
Score=sco;//the constructor
}
Void show_base0 () {//output Base0 data members
Cout
Protected:
Char no [8].//number
Char name [10].//name
The Date birth;//birthday
Float score;//achievement
};
Class Derived: public Base0//Derived classes Derived public inheritance Base0
{
Public:
Derived () {}
Derived (char num [], char nam [], int y, int m, int d, float sco, char ph [15], char address [10]) : Base0 (num, nam, y, m, d, sco)
{
Strcpy (phone, ph);
Strcpy (addr, address);
}
Char * getNo () {return no; }//get number
Void setScore float (sco) {score=sco; }//set grades
Void show_d ()//output data members
{
Show_base0 ();
Cout
Boolean operator==(char num [8]) {//operator overloading, comparing Numbers are equal
If (STRCMP (no, num)==0)
return true;
The else
return false;
}
Friend void inputDerData (Derived d [10], int & amp; Len);//a friend function, read data from a data file
Friend void outputDerData (const Derived d [10], int len);//a friend function, write data to the data file
Private:
Char phone [9].//phone
Char addr [10].//address
};
//from a text file der. Dat read data to the memory array d
Void inputDerData (Derived d [10], int & amp; Len)
{
Ifstream infile (" der. Dat ", the ios: : in);//1. Open the
//define input file stream object, to open the disk file input way f1. Dat
if(! Infile)//2. The judge
{cerr<" The open error!"
}
int i=0;
while(! Infile. Eof ())//3. Read
{infile> D [I] no> D [I]. Name
> D [I] birth. Year> D [I] birth. Month> [I] d. Birth. Day
> D [I] score> D [I] phone> D [I]. Addr.//reading from a disk file, the order in d array
i++;
}
Len=I;
Infile. Close ();//4. Close the
}
Void outputDerData (const Derived d [10], int len)
{//write memory array d data into a text file. Der dat
If (len==0)
return;
Ofstream outfile (" der. Dat ", the ios: : out);
//define input file stream object, to open the disk file input way f1. Dat
if(! Outfile)
{cerr<" The open error!"
}
int i;
For (I=0; I
I=len - 1;
Outfile
}
Bool searchNo (Derived d [10], int len, char number [8])
{//at length for len d find the Numbers for the number of elements in the array, find returns true. Otherwise returns false
int i;
for(i=0; I
{return true; }
}
return false;
}
Void traverse by (Derived d [10], int len) {
//traverse length for len d array
int i;
If (len==0)
{cout<" Pro! Still no data "& lt;
}
}
Int searchIdx (Derived d [10], int len, char number [8])
{//at length for len d find the Numbers for the number of elements in the array, find the return order. Otherwise returns 0
int i;
for(i=0; I
{return I + 1; }
}
return 0;
}
Void insertObj (Derived d [10], int & amp; Len, Derived d1) {
//in the length of d1 len d array into the object, to find the first number, find not insert. Otherwise insert
Bool res=searchNo (d, len, d1 getNo ());
If (res)
{cout
{d [len++]=d1; Cout
Void modifyObj (Derived d [10], int len, char num [8], float newsco) {
//found in length for len d array object d0, modify its performance for newsco
Int index=searchIdx (d, len, num);
If (index)
{cout<" Modify the result for "& lt;
The else
{cout
Void deleteObj (Derived d [10], int & amp; Len, char num [8]) {
//found in length for len d array object d0, modify its performance for newsco
Int index=searchIdx (d, len, num);
If (index)//find the delete
{
For (int I=index - 1; I
Len -;
}
The else
{cout
/*
//read binary data file
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull