home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ for Dummies (3rd Edition)
/
C_FD.iso
/
CHAP25
/
CHAP25_1.CPP
Wrap
C/C++ Source or Header
|
1996-09-02
|
867b
|
64 lines
// Chap25_1.cpp
#include <iostream.h>
class Obj
{
public:
Obj(char c)
{
label = c;
cout << "Constructing object " << label << endl;
}
~Obj()
{
cout << "Destructing object " << label << endl;
}
protected:
char label;
};
void f1();
void f2();
int main(int, char*[])
{
Obj a('a');
try
{
Obj b('b');
f1();
}
catch(float f)
{
cout << "Float catch" << endl;
}
catch(int i)
{
cout << "Int catch" << endl;
}
catch(...)
{
cout << "Generic catch" << endl;
}
return 0;
}
void f1()
{
try
{
Obj c('c');
f2();
}
catch(char* pMsg)
{
cout << "String catch" << endl;
}
}
void f2()
{
Obj d('d');
throw 10;
}