小编Suc*_*Raj的帖子

C++中类对象的大小

在什么基础上,类对象的大小显示为12?

class testvector
{
    public : vector<int> test;
};
int main()
{
    testvector otestvector;
    cout<<"size :"<<sizeof(otestvector)<<"\n";
    cout<<"size of int :"<<sizeof(int);
}
Run Code Online (Sandbox Code Playgroud)

输出:

size :12
size of int :4
Run Code Online (Sandbox Code Playgroud)

c++ sizeof

-1
推荐指数
1
解决办法
3223
查看次数

标签 统计

c++ ×1

sizeof ×1