What are POD types in C++ and why are they needed?
Hello everyone! I started learning C++ and came across the term "POD type". I read the documentation, but still don't fully understand. It seems to be "Plain Old Data", but what does it give in practice?\n\nLet's say I write a simple structure for storing a point:\n\n```cpp\nstruct Point {\n int x;\n int y;\n};\n```\n\nIs it a POD type? And what if I add a constructor?\n\n```cpp\nstruct Point2 {\n Point2() : x(0), y(0) {}\n int x;\n int y;\n};\n```\n\nOr if I add a virtual function?\n\n```cpp\nstruct Point3 {\n virtual void print() {}\n int x;\n int y;\n};\n```\n\nWhy is this important? Where is it used? I heard that POD types can be copied via memcpy, but regular structures cannot. Is that true? And how to check if a type is POD in modern C++?\n\nI would like to get a clear
No answers yet.
Log in to leave an answer
Blogs
Clean Code in JavaScript: Principles and Examples for Node.js