Exception Handling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartway
    New Member
    • Oct 2006
    • 24

    Exception Handling

    How can we do exception handling for declaring object of the class in C++?
  • apiplani
    New Member
    • Oct 2006
    • 8

    #2
    The best check after declaring a new object is to check if it has been allocated the memory or not :

    Class * obj = new Class;

    if ( !obj)
    {
    //raise error...
    }


    Also it would be a good idea to use memset on the newly declared object so that it doesnt carry a garbage value...

    memset ( obj, '\0', sizeof(obj) ;

    Comment

    Working...