类成员原来也可以用已经初始化过的成员来初始化
来源:互联网 发布:学会计软件哪个好 编辑:程序博客网 时间:2024/05/01 11:33
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
}
- 类成员原来也可以用已经初始化过的成员来初始化
- 类成员的初始化
- 类的成员初始化
- 拷贝构造函数,也可以使用成员初始化列表语法
- 类成员的初始化顺序
- 类的成员初始化顺序
- 类的成员初始化顺序
- 类的静态成员初始化
- 类的静态成员初始化。
- 类成员的初始化顺序
- 类的成员初始化顺序
- 类的成员变量初始化
- C++类成员的初始化
- 类成员的初始化顺序
- 类的数据成员初始化
- C++ 类的成员初始化
- C++类成员的初始化
- C++类成员的初始化
- 查找匹配字符串(包含所输入的字符串)
- 通用存储过程之五: 根据查询条件,获取表记录数的存储过程。
- MapGuide 初步
- 使用Hibernate的项目中对VO的理解
- 用Virtual PC安装Redhat的问题的解决方法
- 类成员原来也可以用已经初始化过的成员来初始化
- J2EE架构数据表示:Struts+Hibernate
- 美著名博客称桌面RSS阅读器正走向衰亡
- 关于静态
- ASP.NET(C#)常用代码30例
- 防沉迷与身份证系统挂钩 网游要实名认证
- No English, Chinese please
- (转载)linux安装fms2.0.4
- 这样定义结构体是什么意思??