开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜