C++ 多继承 初步01


class Base1
{
public:
	Base1()
	{
		this->m_A = 10;
	}
	int m_A;
};

class Base2
{
public:
	Base2()
	{
		this->m_A = 20;
	}
	int m_A;
};
//多继承语法 
class Son : public Base1, public Base2
{
public:

	int m_C;
	int m_D;
};
void test01()
{
	cout << sizeof (Son) << endl;
	Son s;
	cout << "Base1中的 m_A = " << s.Base1::m_A << endl;
	cout << "Base2中的 m_A = " << s.Base2::m_A << endl;
}
发布了100 篇原创文章 · 获赞 6 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43903378/article/details/103936591