Hi,
    I have a query related to exceptional handling. I pasted the code I tried 
following this mail.
My intention is , what happens in a sistuation when any exception is caught in 
main , so while destructing the objects till that instant again if any 
exception is caught (stack unwinding concept).
similary in constructor. For constructor I know that the desctructors of the 
sub objects will be called . But how that exception is handled .

#include<stdio.h>
#include<conio.h>
#include<iostream>
using namespace std;
class var1
{
public:
    var1()
    {
        cout<<"I m in var1 conc"<<endl;
    }
    ~var1()
    {
        cout<<"I m in var1 desc"<<endl;
    }
};

class MyCls
{
public:
    var1 *obj;
    MyCls():obj(NULL)
    {
        obj=new var1();
        cout<<"I m in cons"<<endl;
    }
    ~MyCls()
    {
        
        cout<<"I m in desc"<<endl;
        throw "excepto";
        delete obj;
        cout<<"Deleted obj"<<endl;
    }
};

void main()
{
    try
    {
        MyCls obj;
        cout<<"Obj Created"<<endl;
        throw "error";
        cout<<"Obj after throwing err"<<endl;
    }
    catch(char *x)
    {
        cout<<x<<endl;
    }
    catch(...)
    {
        cout<<"I m in last"<<endl;
    }
}


      GopiKrishna Komanduri
Software engineer
[EMAIL PROTECTED]
   

--- On Tue, 25/11/08, Brett McCoy <[EMAIL PROTECTED]> wrote:
From: Brett McCoy <[EMAIL PROTECTED]>
Subject: Re: [c-prog] Exception handling
To: [email protected]
Date: Tuesday, 25 November, 2008, 9:29 PM










    
            On Tue, Nov 25, 2008 at 9:10 AM, crystalcat_75

<crystalcat_75@ yahoo.co. in> wrote:

> Following program is showing an error while running in turbo c :

> undefined symbol for "try"

> statement missing after try .



I don't think Turbo C supports exceptions. You need to upgrade to a

modern compiler like Dev-C++ or MS Visual C++ Express (they are free)

and not use something that is 15+ years old.



-- Brett

------------ --------- --------- --------- --------- --------- -

"In the rhythm of music a secret is hidden;

    If I were to divulge it, it would overturn the world."

               -- Jelaleddin Rumi


      

    
    
        
         
        
        








        


        
        


      Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/

[Non-text portions of this message have been removed]

Reply via email to