本文介绍了结构和类之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Do结构是否支持继承?
Do structures support inheritance? I think it's stupid question, but I have not much idea about it.
这样编写代码的意义是什么:
What is the meaning of writing code like this:
struct A {
void f() { cout << "Class A" << endl; }
};
struct B: A {
void f() { cout << "Class B" << endl; }
};
在结构中,私人部分会来,不是他们给封装吗?结构和类之间的主要区别是什么?
In structures also private section will come, don't they give encapsulation? What is the major difference between structures and classes?
推荐答案
是结构支持类做的所有功能。区别是:
Yes structures support all features that classes do. The differences are:
- 结构继承默认为public
- 结构成员默认为public
这篇关于结构和类之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!