Kırmızı Şapka

RedHat, Uygulama Kurulumu, Ayarlar vs.

Cumartesi, Temmuz 11, 2009

Exception Kullanimi


#include "ConfigException.h"


void test(int t) throw(ConfigException)
{
if (t==4)
{
throw ConfigException("t cannot be 4");
}

}

int main(int argc, char* argv[])
{
try{
if(argc>1){
int input = atoi(argv[1]);
test(input);
}
}
catch (ConfigException& ce) {
cerr<<"Reason: "<< ce.what <<endl;
exit(8);
}
catch (...) {
cerr<<"Unknown error"<<endl;
exit(8);
}
return(0);

}

Etiketler:

Toplam 0 Yorum:

Yorum Gönder

<< Ana Sayfa