问个关于类成员之间的交换问题。
class A
{
Public:
CFile logfile;
Openlog() {logfile.Open("4.txt",CFile::modeCreate|CFile::modeReadWrite);}
Writelog() {logfile.Write("haha",5);}
....
class B
{
Public:
Working();
为什么在B对象里先调用A对象的Openlog函数,接着调用Writelog函数时出现非法操作呢?
我Debug看到logfile为非法句柄,但已是用Openlog初始化了的拉。
其实CFile这只是一个例子,我有很多地方也出现这样的情况。