Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASSERT_VALID?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
wut does ASSERT_VALID do? can u give me a detailed and simple explaination??
 
In MFC you ussualy use classes derived from CObject. When you have a pointer to an object of such kind of class you want to be sure that this pointer is valid. This works only in DEBUG version.

E.g.:
Code:
void function(CWnd* pWnd)
{
ASSERT_VALID(pWnd);

}
The CWnd class is derived from CObject. The following checks are done:
- pointer must be not NULL
- the address pointed must be valid at least a number of sizeof(CObject) bytes. This is useful when the pointer is used not initialised (e.g. the value is 0xcdcdcdcd)
- the virtual table pointer should be valid
- calls AssertValid member function of that object to make specific check. You should overwrite this virtual function and call the base version. Add here your specific check.

If any of these operations fails, a DebugBreak() is raised.

Marius Samoila,
Brainbench MVP for Visual C++
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top