home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Using Visual C++ 4 (Special Edition)
/
Using_Visual_C_4_Special_Edition_QUE_1996.iso
/
ch13
/
cnstruct.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-18
|
733b
|
41 lines
// Get needed include files
#include <iostream.h>
#include <eh.h>
class LocalGuy
{
public:
LocalGuy() { cout << "In the LocalGuy constructor.\n"; }
~LocalGuy() { cout << "In the LocalGuy destructor.\n"; }
};
class Base
{
public:
Base() { cout << "In the Base constructor.\n"; }
~Base() { cout << "In the Base destructor.\n"; }
};
class Derived: public Base
{
public:
Derived(int flag)
{
LocalGuy MyLocalGuy;
cout << "In the Derived constructor.\n";
if (flag)
throw -1;
}
~Derived() { cout << "In the Derived destructor.\n"; }
};
void main()
{
try {
Derived(1);
}
catch (int) {
cout << "Caught the Derived class exception.\n";
}
}