Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Throwing exception and it's messages

I'm new to using CLion and try to write a simple program to understand how it works. I'm on Windows 8 + cygwin the program is:

int main()
{
    throw std::exception();
}

I got in the console the output:

C:\....\bin.exe

Process finished with exit code 0

Where the messages about the program was aborted or something else? There was nothing, and how should I detect if my program was actually aborted by throwing exception?

like image 604
stella Avatar asked Nov 10 '22 10:11

stella


1 Answers

This is done because you don't have try and catch and it happens something like stack unwitted.in a function if you don't have catch it goes down the stack until it reaches main and if there is no catch is terminate.if your function throw an exception without catch it terminate imediately and you go back to The caller function.if The caller function is Main and you don't have catch The program terminate.it goes down The stack and without a catch somewhere in this chain of functions it will terminate The program.

like image 57
Otniel-Bogdan Mercea Avatar answered Nov 15 '22 04:11

Otniel-Bogdan Mercea