c++ - sizeof(空白类)== 1. 为什么?

标签 c++

<分区>

Possible Duplicate:
C++: What is the size of an object of an empty class?

#include <iostream>

class C
{
};

int main()
{
    std::cout << sizeof(C) << std::endl;

    return 0;
}

输出: 1

为什么是 1,而不是零?

最佳答案

关于c++ - sizeof(空白类)== 1. 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3132588/

相关文章:

c++ - 使用指向非静态成员函数的函数指针时,可以省略 "this"关键字吗

c++ - 可使用不同目录中的图像执行

c++ - Qt : Background thread refreshing UI thread

c++ - 异常抛出 : Access violation reading location in VS 2012.(在 VS2010 中没有)

c++ - 当 future 离开范围时,线程会去哪里?

c++ - Qt 4.8.0 - 未列出 MySQL 驱动程序

c++ - 具有虚拟析构函数的基类的子类中的默认析构函数

使用 Visual Studio 2010/Intel 2013 创建的 C++/Fortran 项目不会在 Visual Studio 2015/Intel 2017 中以 Release模式构建

c++ - 无法让 GetModuleFileNameA 工作,不断收到错误 'missing type specifier...'

c++ - 使用 bcrypt 哈希密码进行身份验证