开发者

Borland c++ exception

开发者 https://www.devze.com 2023-01-21 08:44 出处:网络
i am using the Borland c++ 3.1 compiler. I want to work with exceptions, i\'ve written the following code:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消