+ Reply to Thread
Results 1 to 2 of 2

Thread: How to safely delete object or objects?

  1. #1

    How to safely delete object or objects?

    Hi All,

    How to safely delete object or objects?

    Please help.

    Regards.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    EXample:

    Code:
    #define DELET_OBJECT(P)			if (NULL != P) {	delete P ; P = NULL ; } 
    #define DELET_OBJECT_ARRAY(P)	if (NULL != P) {	delete []P ; P = NULL ; } 
    
    void UseSafeDeleteObject()
    {
    	char *pName = new char[10] ;
    	DELET_OBJECT_ARRAY(pName) ;
    
    	CStudent *pStudent = new CStudent() ;
    	DELET_OBJECT(pStudent) ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts