三维数组使用单变量访问,类的大小

来源:互联网 发布:淘宝三大苹果店 编辑:程序博客网 时间:2024/05/29 18:10
#include <iostream>using namespace std;class A {};class B {    void fun()    {    }};int main(){    int three[2][2][3] = { {{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}} };    //三维数组单变量访问,先除再取余。    for (int i = 0;i < 12;++i)    {        cout << three[i / 6][i % 6 / 3][i % 6 % 3] << " ";    }    cout << endl;    cout << "空类\t" << sizeof(A) << endl                 //1        << "类仅含一个有函数体的函数\t" << sizeof(B) << endl;   //函数有无函数体都为1        //若为虚函数,为4,仅需一个指针指向虚函数表    cout<< "\t\t\t\t\t\t@zem" << endl;    system("pause");    return 0;}

这里写图片描述

0 0
原创粉丝点击