.. index:: pair: class; EE::NonCopyable .. _doxid-class_e_e_1_1_non_copyable: class EE::NonCopyable ===================== .. toctree:: :hidden: Overview ~~~~~~~~ Utility class that makes any derived class non-copyable. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class NonCopyable { }; .. _details-class_e_e_1_1_non_copyable: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Utility class that makes any derived class non-copyable. This class makes its instances non-copyable, by explicitely disabling its copy constructor and its assignment operator. To create a non-copyable class, simply inherit from :ref:`EE::NonCopyable `. The type of inheritance (public or private) doesn't matter, the copy constructor and assignment operator are declared private in :ref:`EE::NonCopyable ` so they will end up being inaccessible in both cases. Thus you can use a shorter syntax for inheriting from it (see below). Usage example: .. ref-code-block:: cpp class MyNonCopyableClass : EE::NonCopyable { }; Deciding whether the instances of a class can be copied or not is a very important design choice. You are strongly encouraged to think about it before writing a class, and to use :ref:`EE::NonCopyable ` when necessary to prevent many potential future errors when using it. This is also a very important indication to users of your class.