C++ 中的 POD 类型是什么? [英] What are POD types in C++?

查看:37
本文介绍了C++ 中的 POD 类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我多次遇到过这个术语 POD 类型.
这是什么意思?

I've come across this term POD-type a few times.
What does it mean?

推荐答案

POD 代表 Plain Old Data - 即一个类(无论是用关键字struct 或关键字 class) 没有构造函数、析构函数和虚成员函数.维基百科关于 POD 的文章 更详细地将其定义为:

POD stands for Plain Old Data - that is, a class (whether defined with the keyword struct or the keyword class) without constructors, destructors and virtual members functions. Wikipedia's article on POD goes into a bit more detail and defines it as:

C++ 中的普通旧数据结构是一个聚合类,它只包含 PODS 作为成员,没有用户定义的析构函数,没有用户定义的复制赋值运算符,也没有成员指针类型的非静态成员.

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.

更多细节可以在C++98/03的这个答案中找到.C++11 改变了围绕 POD 的规则,大大放松了它们,因此需要在此处进行后续回答.

Greater detail can be found in this answer for C++98/03. C++11 changed the rules surrounding POD, relaxing them greatly, thus necessitating a follow-up answer here.

这篇关于C++ 中的 POD 类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆