Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:58:36+00:00 2026-06-10T10:58:36+00:00

It is my understanding that all exceptions in c++ ultimately extend exception . In

  • 0

It is my understanding that all exceptions in c++ ultimately extend exception. In Java world, catching Exception e would have worked regardless of the type of Exception. How is this done in C++?

Why is that in this snippet exception is not caught?

try{        
    int z = 34/0;
    cout << "This line should not appear" << endl;
} catch (exception e) {
    cout << "An error has occurred: " << e.what();  // Not executed
}

Also, in C++, how can one find out what actions causes what exception?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:58:38+00:00Added an answer on June 10, 2026 at 10:58 am

    Why is that in this snippet exception is not caught?

    An integer divided by 0 is not a standard c++ exception. So no exception is thrown in this case what you get is an plain Undefined Behavior.

    Some specific compilers might map this scenario to an particular exception and you will have to check your compiler documentation to find the same.However, using such a feature will be non-portable and your code will be restricted to your specific compiler.

    The best you can do in such a scenario is to check the error condition(divisor equals zero) yourself and throw an exception explicitly.

    Also, in C++, how can one find out what actions causes what exception?

    The std::exception class provides a method std::exception::what() specifically for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's my understanding that all three of these lines below should return an ARRAY
It's my understanding that all .NET object instances begin with an 8 byte 'object
It's my understanding that in Spring, all objects are treated by default as singletons.
My original understanding was that the asp.net page lifecycle is run once for all
From my understanding, the soft keyboard is actually a dialog window that underlies all
It is my understanding that two unequal objects can have the same hashcode. How
I'm of the understanding that an unhandled exception in any appdomain will bring down
It is my understanding that, in addition to allocating memory, alloc sets all instance
It's my understanding we have essentially 2 kinds of exceptions when using NServiceBus. Environmental
Ok, I have a strange exception thrown from my code that's been bothering me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.