Menu

C++ Orthodox Canonical Form
📰

C++ Orthodox Canonical Form

DEV Community: cpp·Yunus Emre Ak·6 days ago
#XOfnoCzv
#devtocpp#devto#dev#include#human
Long article (1333 words) — no AI summary yet.
Reading 0:00
15s threshold

There are 6 special member functions for structs or classes. We are here for object oriented programming, so I will give examples using classes.

Special member functions:

Special Member Function Task

Default Constructor Creates a default object

Copy Constructor Creates a new copy of the object

Copy Assignment Operator Copies to the existing object

Move Constructor (C++11) Creates a new object and moves the resources to the object

Move Assignment Operator (C++11) Moves the resources to the existing object

Destructor Destroys the object

These functions are implicitly declared when needed by compiler. Explicitly defining all special member functions is not always necessary. In modern C++, the Rule of Zero recommends relying on automatically generated special member functions whenever possible.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.