类的继承与sizeof
生活随笔
收集整理的這篇文章主要介紹了
类的继承与sizeof
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、程序
#include "iostream" #include "cstdlib" using namespace std;class A {private: //私有成員 int m_data;};class B: private A //私有繼承 {private:int m_data; };class C: private B //私有繼承 {private:int m_data; };int main() {cout<<sizeof(A)<<endl; //4cout<<sizeof(B)<<endl; //8cout<<sizeof(C)<<endl; //12system("pause");return 0; }
二、運(yùn)行結(jié)果
總結(jié)
以上是生活随笔為你收集整理的类的继承与sizeof的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 二叉排序树的建立、先序/中序/后序遍历、
- 下一篇: 横空出世,席卷互联网--评微软等公司数据