r+: Open for reading and writing. The stream is positioned at the beginning of the file. w+:Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the f…
fopen <cstdio> FILE * fopen ( const char * filename, const char * mode ); Open file Opens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by the FILE object whose…
转自 http://blog.csdn.net/todd911/article/details/8976543 r 打开只读文件,该文件必须存在. r+具有读写属性,从文件头开始写,保留原文件中没有被覆盖的内容.该文件必须存在. w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失.若文件不存在则建立该文件. w+ 打开可读写文件,若文件存在则文件长度清为零,即该文件内容会消失.若文件不存在则建立该文件. a 以附加的方式打开只写文件.若文件不存在,则会建立该文件,如果文件存在,写入…
多态 (一) 先编写函数: #include <iostream> using namespace std; class Shape { protected: int width, height; public: Shape( int a = 0, int b = 0) { width = a; height = b; } int area() { cout << "Parent class area :" <<endl; return 0; } }…