简体   繁体   中英

Borland c++ exception

i am using the Borland c++ 3.1 compiler. I want to work with exceptions, i've written the following code:

void main (void) {
    int a = 0;
    int b = 1;
    int c;
    try {
        throw 1;
    }
    catch(int a) {
        b = a;
    }
}

The compiler returns a syntax error. what's wrong?

Most compilers will issue an error stating that your main function must return an int. The main function must return int in a C++ program. It's unsafe to return void from a main function and many modern compilers won't compile. Aside from that everything looks compilable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM