Ray Tracer
2020
|
NonCopyable class. More...
#include <NonCopyable.h>
Protected Member Functions | |
NonCopyable () | |
NonCopyable default constructor. More... | |
~NonCopyable () | |
NonCopyable destructor. More... | |
Private Member Functions | |
NonCopyable (const NonCopyable &) | |
NonCopyable copy constructor. More... | |
NonCopyable & | operator= (const NonCopyable &) |
NonCopyable assignment operator. More... | |
NonCopyable class.
Sometimes it doesn't make sense for an object to be duplicated. This may be for technical reasons (such as the class representing a limited physical resoruce), and sometimes for practical reasons (such as the class storing lots of information). In C++ this can be enforced by explicitly deleting the copy constructor and assignment operator, or by making them private. The NonCopyable class makes this easy and less error prone to do. To make a class NonCopyable, just inherit (privately) from NonCopyable:
|
inlineprotected |
NonCopyable default constructor.
|
inlineprotected |
NonCopyable destructor.
|
private |
NonCopyable copy constructor.
Note that there is no implementation for the copy constructor. You cannot copy construct NonCopyable objects.
|
private |
NonCopyable assignment operator.
Note that there is no implementation for the assignment operator. You cannot assign NonCopyable objects.