Home > Articles > Programming > C/C++

C++ Reference Guide

Hosted by

Toggle Open Guide Table of ContentsGuide Contents

Close Table of ContentsGuide Contents

Close Table of Contents

POD (Plain Old Data) and Non–POD Objects

Last updated Jan 1, 2003.

C++ distinguishes between two types of objects: POD (plain old data) and non–POD objects. A POD object has one of the following datatypes: a built-in type, pointer, union, struct, array, or class with a trivial constructor. For example:

int n;
class C
 int j,k;
C c; // c is a POD object
struct S
 int j,k;
S s;
char *pc;
bool barr[10];

Conversely, a non–POD object is one for which a nontrivial constructor exists. Note that this distinction between POD and non–POD doesn't exist in pure object-oriented languages; it's an artifact of the hybrid nature of C++. It's used to differentiate between traditional C datatypes and real C++ objects. A POD object begins its lifetime when it obtains storage with the proper alignment and size for its type, and its lifetime ends when the storage for the object is either reused or deallocated. A non–POD object begins its lifetime after its constructor has executed; its lifetime ends when its destructor has started.