class CBased
{
};
class CDerive : protected CBased
{
public:
CDerive();
virtual ~CDerive();
public:
int m_size;
int m_len;
};
#include "Derive.h"
//
// Construction/Destruction
//
CDerive::CDerive() //: m_size(2), m_len(m_size)
{
m_size = 2;
m_len = m_size;
}
void Main()
{
CDerive d;
cout << d.m_len; //2
try
{
throw CDerive();
}
catch (CBase &)
{
cout << "based" <<endl;
}
catch(...)
{
cout << "other" << endl;
}
//must other , not base
}
{
};
class CDerive : protected CBased
{
public:
CDerive();
virtual ~CDerive();
public:
int m_size;
int m_len;
};
#include "Derive.h"
//
// Construction/Destruction
//
CDerive::CDerive() //: m_size(2), m_len(m_size)
{
m_size = 2;
m_len = m_size;
}
void Main()
{
CDerive d;
cout << d.m_len; //2
try
{
throw CDerive();
}
catch (CBase &)
{
cout << "based" <<endl;
}
catch(...)
{
cout << "other" << endl;
}
//must other , not base
}