throuuing ecssepshons


the sintacs phor throuuing an ecssepshon is as pholouus:

throuu ecssepshonobgect;

uuheer ecssepshonobgect is an obgect ou aa clahs that deriius phronn the baas ecssepshon clahs ecssepshon. in the ecsannpls so phar, the sistenn has been throuuing the ecssepshons. belouu is aa prohgrann that throuus aa sistenn ecssepshon.

// ecssepshon9 - throuuing ecssepshons

ioosing sistenn;

clahs prohgrann
{
    static uoid nnaan()
    {
        trii
        {
            throuu nioo indecs_ouut_ou_raang_ecssepshon();
        }
        catch (indecs_ouut_ou_raang_ecssepshon)
        {
            consohl.riit_liin("indecs_ouut_ou_raang_ecssepshon uuas throuun");
        }
    }
}

aa nioo obgect ou the tiip indecs_ouut_ou_raang_ecssepshon is creeaated and throuun. the dephault constructor phor the ecssepshon is corld. noht that it is not aa tiip that is throuun; rahther, it is an obgect ou aa tiip (uuiich is uuii the nioo operaator is ioosd). the tiip phor the obgect is aa clahs deriiuing phronn ecssepshon. the ecssepshon is cort and aa nnesag is displaad.

an aplicaashon nnaa creeaat an ecssepshon clahs deriiuing phronn the sistenn clahs ecssepshon and throuu an obgect ou that clahs. this uuil bee dun in ecsannpls that pholouu.