ASSERT_VALID( pObject )

一个宏,用来验证值是否不为null.

参数: pObject 指定了从CObject继承的类的对象,它具有AssertValid成员函数的重载版本。

说明:
这个函数用于检验你对对象内部状态的有效性的假定。ASSERT_VALID调用作为参数传递给它的对象的AssertValid成员函数。
在MFC的发行版本中,ASSERT_VALID什么也不做。在调试版本中,它检验一个指针是否为NULL,并且调用对象自己的AssertValid成员函数。如果这些测试中有些失败了,它就按照与ASSERT相同的方式显示一个警告信息。
注意:这个函数仅在MFC的调试版本中才有。
有关的更多信息以及示例参见《Visual C++程序员指南》中的“MFC 调试支持”。

请参阅:
ASSERT, VERIFY, CObject, CObject::AssertValid

ASSERT_VALID
ASSERT_VALID( pObject )

Parameters

pObject

Specifies an object of a class derived from CObject that has an overriding version of the AssertValid member function.

Remarks

Use to test your assumptions about the validity of an object’s internal state. ASSERT_VALID calls the AssertValid member function of the object passed as its argument.

In the Release version of MFC, ASSERT_VALID does nothing. In the Debug version, it validates the pointer, checks against NULL, and calls the object’s own AssertValid member functions. If any of these tests fails, this displays an alert message in the same manner as ASSERT.

Note This function is available only in the Debug version of MFC.

For more information and examples, seeMFC Debugging Support in Visual C++ Programmer’s Guide.

Example

// Assure that pMyObject is a valid pointer to an
// object derived from CObject.
ASSERT_VALID(pMyObject);

/
ASSERT
ASSERT( booleanExpression )

Parameters

booleanExpression

Specifies an expression (including pointer values) that evaluates to nonzero or 0.

Remarks

Evaluates its argument. If the result is 0, the macro prints a diagnostic message and aborts the program. If the condition is nonzero, it does nothing.

The diagnostic message has the form

assertion failed in file <name> in line <num>

where name is the name of the source file, and num is the line number of the assertion that failed in the source file.

In the Release version of MFC, ASSERT does not evaluate the expression and thus will not interrupt the program. If the expression must be evaluated regardless of environment, use the VERIFY macro in place of ASSERT.

Note This function is available only in the Debug version of MFC.

Example

// example for ASSERT
CAge* pcage = new CAge( 21 ); // CAge is derived from CObject.
ASSERT( pcage!= NULL )
ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CAge ) ) )
// Terminates program only if pcage is NOT a CAge*.

ASSERT_VALID相关推荐

  1. vs2008中,在OCX控件中应用doc/view基本步骤

    1.利用向导创建一个MFC ActiveX Control控件CMyOCX: 2.在工程中加入ActivDoc头文件和执行文件: class CActiveXDocTemplate : public ...

  2. MFC中快速应用OpenCV(转)

    转载链接:http://wiki.opencv.org.cn/index.php/MFC%E4%B8%AD%E5%BF%AB%E9%80%9F%E5%BA%94%E7%94%A8OpenCV 简介和缘 ...

  3. AssertValid函数学习

    转自http://tsitao.blog.163.com/blog/static/29795822006914105840496/ VC的调试中,AssertValid和Dump函数的应用 CObje ...

  4. JAVA实现中点画线_实验1-中点画线和Bresenham画线算法的实现

    <实验1-中点画线和Bresenham画线算法的实现>由会员分享,可在线阅读,更多相关<实验1-中点画线和Bresenham画线算法的实现(9页珍藏版)>请在人人文库网上搜索. ...

  5. 13_MFC工具条和状态栏

    MFC工具条和状态栏 Windows控制窗口 Windows (Windows95或者以上版本) 提供了系列通用控制窗口,其中包括工具条(ToolBar).状态栏(StatusBar).工具条提示窗口 ...

  6. BMP文件的读取与显示

    有三个函数能够完毕这一功能 1.BitBlt BitBlt 用于从原设备中复制位图到目标设备 void CMFCApplication1View::OnDraw(CDC* pDC) {CMFCAppl ...

  7. 在 VC6 中使用 GdiPlus-使用

    下面用 VC6 来写一个 GdiPlus 的 Demo 工程 Step1:新建一个名为 Demo_GdiPlus 的 MFC AppWizard(exe) 工程 操作步骤: (1)主菜单File-&g ...

  8. 关于Debug和Release编译方式

    问:怎么在VC6中把工程编译成release版本? 答:可以project->Set Active Config,选中release版本.此后,按F5或F7编译所得的结果就是release版本. ...

  9. 界面Hello world

    // CMyFirstAppView 绘制void CMyFirstAppView::OnDraw(CDC* pDC) {CMyFirstAppDoc* pDoc = GetDocument();AS ...

最新文章

  1. 洛谷 - P2765 魔术球问题(最大流+残余网络上的最大流+路径打印)
  2. java set的first_Java TreeSet pollFirst()方法与示例
  3. bean包、entity包、mode包、domain包的区别
  4. celery的中文_celery异步任务框架
  5. Python爬虫项目:抓取智联招聘信息
  6. Python抽象及异常处理
  7. 拓端tecdat|R软件SIR模型网络结构扩散过程模拟
  8. 更换yum源-阿里yum源
  9. 《头脑王者》--在线排位答题系统构思
  10. 星空粒子登录页面 jsp
  11. Kafka代码实现--from-beginning,读取历史未消费的数据
  12. 微创电生理递交注册:拟募资10亿 核心设备高度依赖单一供应商
  13. windows设置CPU主频
  14. 模型学习01——评价类模型(1)
  15. 【期末复习】计算机组成原理
  16. 佰落暑期java自学记录-1
  17. 解决addClass不起作用的小妙招
  18. 计算机BIOS介绍,BIOS详细的介绍说明
  19. dell服务器boss卡安装系统,Dell BOSS 卡是什么
  20. mysql数据库的备份与还原(windows和linux下)

热门文章

  1. Camstar CDO增加自定义字段
  2. linux中的.rc文件介绍
  3. Dplayer直播m3u8流
  4. 能用10年的电动车牌子是什么?绿源电动车了解一下吧
  5. 2022年湖北荆门助理工程师职称评审条件是什么呢? 甘建二
  6. 高数-导数-求导计算--基本公式
  7. 移动端」H5页面长按复制功能实现
  8. SQL LIKE操作符、通配符以及通配符的使用
  9. Matlab:绘制琼斯矩阵的偏振图像
  10. python图片转手绘