Home > Back-end >  O great god teach novice novices don't know how to operate
O great god teach novice novices don't know how to operate

Time:09-26

I already know how c + + program into the MFC requirements
The file needs to be established in the operating system, and in accordance with the above format manual entry several records, programs corresponding data read from the file first, and then complete the above function
#include
#include
#include
#include
using namespace std;
The class the Teacher//declare the Teacher class
{public:
The Teacher () {}
The Teacher (string nam, int a, char s, a string of AD, string t, string tit) : name (nam), age (a), sex (s), addr (AD), tel (t), title (tit) {}
Void the display ();
Protected:
String name;
int age;
char sex;
String addr.
String tel;
String title;
};//the Teacher class member function definition of

Void the Teacher: : display ()
{cout<" Name: "& lt; Cout<" Age: "& lt; Cout<" Sex: "& lt; Cout<" Address: "& lt; Cout<" Tel: "& lt; Cout<" Title: "& lt; }
The class Cadre//statement class Cadre
{public:
Cadre () {}
Cadre (string nam, int a, char s, a string of AD, string t, string tit, string p) : name (nam), age (a), sex (s), addr (AD), tel (t), title (tit), post (p) {}
Void the display ();
Protected:
String name;
int age;
char sex;
String addr.
String tel;
String title;
The string post;
};//Cadre class member function definition of

Void Cadre: : display ()
{cout<" Name: "& lt; Cout<" Age: "& lt; Cout<" Sex: "& lt; Cout<" Address: "& lt; Cout<" Tel: "& lt; Cout<" Title: "& lt; Cout<" Post: "& lt; }
Class Teacher_Cadre: public the Teacher, public Cadre//declare multiple utility derived class Teacher_Cadre class
{public:
Teacher_Cadre ()
{
}
Teacher_Cadre (string nam, int a, char s, a string of AD, string t, string tit, string p, float w) : the Teacher (nam, a, s, AD, t, tit), Cadre (nam, a, s, AD, t, tit, p), wages (w) {}
Void the show ();
Private:
Float wages;
};

Void Teacher_Cadre: : show ()
{the Teacher: : display ();//specify the domain
Cout<" Post: "& lt; Cout<" Wages: "& lt; }
Int main ()
{void save_to_file ();
Void get_from_file ();
Teacher_Cadre te_ca (39, "Wang", "f", "QingNianDaJie", "0245656896", "JAVA" and "President", 5738.0);
Te_ca. The show ();
Save_to_file ();
Get_from_file ();
system("pause");
return 0;
}
Void save_to_file ()
{ofstream outfile (" Teacher_Cadre. TXT ", the ios: : out);
if(! Outfile)
{cerr<" The open error!" The exit (1);
}
Outfile<" Wang "& lt; Outfile<" 39 "& lt; Outfile<'f' & lt; Outfile<" QingNianDaJie "& lt; Outfile<" 0245656896 "& lt; Outfile<" JAVA "& lt; Outfile<" President "& lt; Outfile<" 5738.0 "& lt; Outfile. Close ();
}
Void get_from_file ()
{ifstream infile "Teacher_Cadre. TXT", the ios: : (in);
if(! Infile)
{cerr<" The open error!" The exit (1);
}
Infile. Close ();
}
  • Related