What are POD types in C++?


POD is an acronym in C++ that means plain old data. It is a class/struct that ONLY has member variables and no methods, constructors, destructors, virtual functions, etc. For example,

Example

#include<iostream>
using namespace std;
// POD
struct MyStruct {
    int key;
    string data;
};
int main() {
    struct MyStruct s;
    s.key = 1;
    s.data = "hello";
    return 0;
}

The struct MyStruct has no user-defined ctor, dtor, etc and hence is a POD.

Updated on: 02-Mar-2020

932 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements