throw() 可以抛出异常

// test the throw

#include<iostream>
using namespace std;

void func()
{
    cout << "generate exception" << endl;
    throw 5;

}

int main()
{
    try{
        func();

    }
    catch(int value)
    {

        cout << "accept exception " << endl;
        
    }

    return 0;
}

猜你喜欢

转载自www.cnblogs.com/zijidefengge/p/12453802.html