Identifying error in constructor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mthread

    #1

    Identifying error in constructor

    Hi,
    I am writing an application in which I do quite a lot of
    initialization in constructor(I am new to C++). There are
    possibilities the costructor might fail. How do I identify whether a
    constructor is failed or not.

  • Kira Yamato

    #2
    Re: Identifying error in constructor

    On 2008-02-08 05:03:27 -0500, mthread <rjkumr@gmail.c omsaid:
    Hi,
    I am writing an application in which I do quite a lot of
    initialization in constructor(I am new to C++). There are
    possibilities the costructor might fail. How do I identify whether a
    constructor is failed or not.
    A::A()
    try
    : b(0), s("hello")
    {
    // body of construction
    }
    catch(some_exce ption &e)
    {
    // If construction of b or s fails, or the code in the body of
    construction fails,
    // then you get here.
    // The constructor will automatically rethrow the exception.
    }

    --

    // kira

    Comment

    Working...