c++ - C++ 中的 POD 类型是什么?

标签 c++ types c++-faq

我曾多次遇到过 POD-type 这个术语。
这是什么意思?

最佳答案

POD 代表 Plain Old Data - 即一个类(无论是使用关键字 struct 还是关键字 class ) 没有构造函数、析构函数和虚成员函数。 Wikipedia's article on POD更详细一点并将其定义为:

A Plain Old Data Structure in C++ is an aggregate class that contains only PODS as members, has no user-defined destructor, no user-defined copy assignment operator, and no nonstatic members of pointer-to-member type.

更多详情请见 this answer for C++98/03 . C++11 改变了围绕 POD 的规则,大大放松了它们,因此 necessitating a follow-up answer here .

关于c++ - C++ 中的 POD 类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/146452/

相关文章:

c++ - unique_ptr 丢失范围时读取访问冲突

c - x86-64 处理器的数据类型

c++ - 什么是 undefined reference /未解析的外部符号错误以及如何修复它?

types - 有没有办法使用 OCaml 类型系统来强制执行有关值的规则?

types - OCaml 中模块包含的类型约束

c++ - 为什么 iostream::eof 在循环条件(即 `while (!stream.eof())` )内被认为是错误的?

c++ - 为什么模板只能在头文件中实现?

c++ - 使用 LinkedList 检查值

c++ - 定义全局数组的运行时间成本?

c++ - 重载运算符的德摩根定律优化