Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Aggregates and PODs 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.
An aggregate is an array or a class with no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions.
An aggregate class is called a POD if it has no user-defined copy-assignment operator and destructor and none of its non-static members is a non-POD class, array of non-POD, or a reference.
Advertisements