LZ还是先补一下C++的基础吧
我来解释一下:
1 定义一个CFile对象
2 对象名为fileSource
3 调用构造对该对象进行初始化(运行时)
4 构造函数包含两个参数
查看MSDN对于该构造函数的原型描述
-----------------来自MSDN------------------
CFile( LPCTSTR lpszFileName, UINT nOpenFlags );
throw( CFileException );
------------------END MSDN----------------------------
务必注意:
1 该构造函数在出错时会抛出异常,所以得捕获异常。
2 第一个参数没什么好说的了,就是一个文件名,数据类型是LPCTSTR
第二个参数,是打开标志,查看CFile类的定义:
----------------------来自 CFile 类定义--------------
enum OpenFlags {
modeRead = 0x0000,
modeWrite = 0x0001,
modeReadWrite = 0x0002,
shareCompat = 0x0000,
shareExclusive = 0x0010,
shareDenyWrite = 0x0020,
shareDenyRead = 0x0030,
shareDenyNone = 0x0040,
modeNoInherit = 0x0080,
modeCreate = 0x1000,
modeNoTruncate = 0x2000,
typeText = 0x4000, // typeText and typeBinary are used in
typeBinary = (int)0x8000 // derived classes only
};
------------------------------END-------------------------------------
采用枚举变量来作为构造函数的第二个参数,在访问时需要加上CFile:作用域。
|