TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  OLC#001Checked automatically with code checker

Synopsis:If objects of a class should never be copied, then the copy constructor and the copy assignment operator shall be declared as deleted functions
Language:C++
Severity Level:2
Category:Object Life Cycle


Description:

Use deleted functions instead of old-fashioned private declarations to prohibit copying.

Wrong example:

class SomeClass {
private:
  SomeClass(SomeClass const&);
  SomeClass& operator=(SomeClass const&);
};

Right example:

class SomeClass {
public:
  SomeClass(SomeClass const&) = delete;
  SomeClass& operator=(SomeClass const&) = delete;
};



Literature References:
ISC++ Rec. 5.10