codetemp-2: CObject::AssertValid()

codetemp-2: CObject::AssertValid()原型:[virtual]voidCObject::AssertValid()const//说明:该成员函数只能对成员变量做”引用型”操作,不能做”加工型”操作{ASSERT(this!=NULL);}MSDN:Whenyouwriteyourownclass,youshouldoverridetheAssertValidfunc…

大家好,又见面了,我是你们的朋友全栈君。

原型:[virtual]

void CObject::AssertValid()
const            //说明:该成员函数只能对成员变量做”引用型”操作,不能做”加工型”操作
{

 ASSERT(this != NULL);

}

MSDN:

When you write your own class, you should override the AssertValid function to provide diagnostic(诊断) services for yourself and other users of your class. The overridden AssertValid usually calls the AssertValid function of its base class before checking data members unique to the derived class.

Because AssertValid is a const function, you are not permitted to change the object state during the test. Your own derived class AssertValid functions should not throw exceptions but rather should assert whether they detect invalid object data.

DEMO:

请查看MSDN中CObject

转载于:https://www.cnblogs.com/shanzy/archive/2005/12/17/299229.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/159756.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号