62 - Exceptions

#include 
using namespace std;

int main()
{
    try
    {
        int momsage = 30;
        int sonsage = 34;
        if(sonsage > momsage)
        {
            throw 99;
        }
    }
    catch(int x)
    {
        cout << "son can not be older, error " << x << endl;
    }
}

你可能感兴趣的:(62 - Exceptions)