第7讲 基于C++流类库的文件输入输出.ppt

第7讲 基于C++流类库的 文件输入输出 本讲主要内容 1. 基于C++流类库的文本文件的读写 2. 基于C++流类库的二进制文件的读写 3. C++程序的结构 【例6-1】 文本文件的读写 在本例中,定义了3个学生对象Student1、Student2和Student3。首先进行了打开文件操作,将这些学生对象的信息以文本数据的形式写入了文本文件“StudentInfo.txt”,再通过读取该文件,将这些信息读入了另外3个学生对象Student1_1、Student2_1和Student3_1中,最后将Student1_1、Student2_1和Student3_1的信息进行了输出。 #include iostream #include fstream using namespace std; class CDate { int m_nYear; int m_nMonth; int m_nDay; public: CDate(int nYear, int nMonth, int nDay); int GetYear(); int GetMonth(); int GetDay(); }; …… class CPerson { protected: char* m_strName; char*

文档评论(0)

1亿VIP精品文档

相关文档