摘要:
C++ 通过以下几个类支持文件的输入输出:ofstream: 写操作(输出)的文件类 (由ostream引申而来) ifstream: 读操作(输入)的文件类(由istream引申而来) fstream: 可同时读写操作的文件类 (由iostream引申而来) 打开文件(Open a file)对这些类的一个对象所做的第一个操作通常就是将它和一个真正的文件联系起来,也就是说打开一个文件。被打开的文件在程序中由一个流对象(stream object)来表示 (这些类的一个实例) ,而对这个流对象所做的任何输入输出操作实际就是对该文件所做的操作。要通过一个流对象打开一个文件,我们使用它的成员函数o 阅读全文
摘要:
#include <fstream> ,相当于是引用标准C++的头文件,ifstream是标准C++的STL中的类,STL中的类都是定义在std这个名字空间中。 所以std::ifstream sitelist( "sitelist ",ios::nocreate); 就是使用std这个名字空间中定义的ifstream这个类,而且这样使用这个类就没有出现在全局名字空间中。 而 #include <fstream.h> ,相当于使用了VC实现的C++提供的头文件,此时ifstream虽有相同的功能,可是他现在相当于是全局名字空间中定义的了。相当于: : 阅读全文
摘要:
C++ 类中的静态变量转自http://blog.csdn.net/zieckey/archive/2006/11/23/1408767.aspx作者:zieckey 一切权利归作者所有静态数据成员:下面看一个例子:#include <iostream.h>class Point{public:void output(){}static void init(){ } };void main( void ){Point pt;pt.init();pt.output(); }这样编译是不会有任何错误的。下面这样看#include <iostream.h>class Poin 阅读全文