CObject { ... public: #ifdef _DEBUG virtual void Dump( CDumpContext& dc ) const; #endif .... }MFC supplies a predefined CDumpContext object named afxDump that you will normally use for routine object dumping.In Windows NT, afxDump output is sent to the debugger, if present. Otherwise, you won’t get any afxDump output.Note afxDump is defined only in the debug version of MFC.
你个鸟人,什么题你都答,把 MSDN COPY 过来就完事了,可以的话我早 COPY 了
哈哈 这还是用家里话讲吧 主要用来提供MFC类诊断信息输出的
Dump 函数用来按指定的格式输出一个对象的成员变量,来帮助你诊断一个对象的内部情况。与AssertValid成员函数一样,Dump也是Cobject 类的成员函数。Dump函数的参数是一个CdumpContext对象,你可以象利用流一样往向这个对象中输入数据。当你创建一个Cobject继承而来的 新类时,你可以按如下步骤重载你自己的Dump函数: (1) 调用基类的Dump函数,以输出基类的内容; (2) 向Cdumpcontest对象输出该类的数据. 例如,典型的Dump函数定义如下: #ifdef _DEBUG void CPerson::Dump( CDumpContext& dc ) const { // call base class function first CObject::Dump( dc );
// now do the stuff for our specific class dc << "last name: " << m_lastName << "\n" << "first name: " << m_firstName << "\n"; } #endif 你可能已经注意到整个函数的定义都包含在#ifdef _DEBUG 和#endif中,这使得Dump成员函数只在DEBUG版本中发生作用,而对RELEASE版本不发生作用。
int x = 1; int y = 16; float z = 32.0; TRACE( "This is a TRACE statement\n" ); TRACE( "The value of x is %d\n", x ); TRACE( "x = %d and y = %d\n", x, y ); TRACE( "x = %d and y = %x and z = %f\n", x, y, z ); 要注意的是TRACE宏只对Debug 版本的工程产生作用,在Release 版本的工程中,TRACE宏将被忽略。
{
...
public:
#ifdef _DEBUG
virtual void Dump( CDumpContext& dc ) const;
#endif
....
}MFC supplies a predefined CDumpContext object named afxDump that you will normally use for routine object dumping.In Windows NT, afxDump output is sent to the debugger, if present. Otherwise, you won’t get any afxDump output.Note afxDump is defined only in the debug version of MFC.
这还是用家里话讲吧
主要用来提供MFC类诊断信息输出的
(1) 调用基类的Dump函数,以输出基类的内容;
(2) 向Cdumpcontest对象输出该类的数据.
例如,典型的Dump函数定义如下:
#ifdef _DEBUG
void CPerson::Dump( CDumpContext& dc ) const
{
// call base class function first
CObject::Dump( dc );
// now do the stuff for our specific class
dc << "last name: " << m_lastName << "\n"
<< "first name: " << m_firstName << "\n";
}
#endif
你可能已经注意到整个函数的定义都包含在#ifdef _DEBUG 和#endif中,这使得Dump成员函数只在DEBUG版本中发生作用,而对RELEASE版本不发生作用。
与此相配套,每当我们创建从Cobject类继承而来的一个新的类时,我们可以重载该成员函数,以执行特定的合法性检查。 TRACE 宏有点象我们以前在C语言中用的Printf函数,使程序在运行过程中输出一些调试信息,使我们能了解程序的一些状态。但有一点不同的是:TRACE 宏只有在调试状态下才有所输出,而以前用的Printf 函数在任何情况下都有输出。和Printf 函数一样,TRACE函数可以接受多个参数如:
int x = 1;
int y = 16;
float z = 32.0;
TRACE( "This is a TRACE statement\n" );
TRACE( "The value of x is %d\n", x );
TRACE( "x = %d and y = %d\n", x, y );
TRACE( "x = %d and y = %x and z = %f\n", x, y, z );
要注意的是TRACE宏只对Debug 版本的工程产生作用,在Release 版本的工程中,TRACE宏将被忽略。