HOW to work with exception handling, i have error UNDEFINED SYMBOL TRY IN C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TINTU
    New Member
    • May 2014
    • 1

    HOW to work with exception handling, i have error UNDEFINED SYMBOL TRY IN C++

    #include<iostre am.h>
    #include<conio. h>
    int main()
    {
    int x,y;
    clrscr();
    cout<<"ENTER VALUES FOR X AND Y"<<"\n";
    cin>>x>>y;
    int j;
    j=x>y?0:1;

    try
    {

    if(j==0)
    {
    cout<<"SUBTRACT ION OF X AND Y"<<(x-y)<<"\n";
    }

    else
    {
    throw(j);
    }

    }

    catch(int k)
    {
    cout<<"EXCEPTIO N CAUGHT: j= "<<j<<"\n";
    }
    getch();
    return 0;
    }


    Saved as EXECP.CPP.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are using iostream.h which is the 1998 version of C++. Very old. In those days many compilers did not have exception handling turned on by default. You might look in your project properties for a switch to enable exception handling.

    Comment

    Working...