Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) POD

 

POD is as abbreviation on 'plain old data (type)'. A POD is also called 'a C-style struct' or an aggregate. A POD is a class without member function and private members.

 

 

 

 

 

Example

 

struct Pod
{
  int x;
  double y;
  bool z;
};

int main()
{
  Pod p;
  p.x = 1;
  p.y = 3.14;
  p.z = true;
}

 

 

 

 

 

Advice

 

 

 

 

 

 

Reference

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 16.4. Advice. page 479: '[3] Use public data (structs) only when it really is just data and no invariant is meaningful for the data members'
  2. Herb Sutter, Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. 2005. ISBN: 0-32-111358-6. Chapter 41: 'Make data members private, except in behaviourless aggregates (C-style structs).

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml