Difference between revisions of "Cpp Coding Standards/Class Construction, Destruction and Copying"
From Apache OpenOffice Wiki
m |
m |
||
Line 25: | Line 25: | ||
=== Related Rules === | === Related Rules === | ||
* [[../Class Design#NoConv |CLSDESIGN:NoConv]]- No Implicit Conversions | * [[../Class Design#NoConv |CLSDESIGN:NoConv]]- No Implicit Conversions | ||
− | * [[../Error Handling# | + | * [[../Error Handling#NoFail |ERR:NoFail]] - Which Functions Never Fail |
* [[../Virtual Classes#RightDestr |VIRTUAL:RightDestr]] - Right Destructor | * [[../Virtual Classes#RightDestr |VIRTUAL:RightDestr]] - Right Destructor | ||
* [[../Virtual Classes#SafeCopy |VIRTUAL:SafeCopy]] - Safe Copying | * [[../Virtual Classes#SafeCopy |VIRTUAL:SafeCopy]] - Safe Copying |
Revision as of 23:03, 29 November 2006
Topic-Id: CLSINIT
Special issues of constructors, copying and destructors.
Contents
Summary
No Virtual Calls in Constructor or Destructor (NoVirt)
Don't call your own class' virtual functions in a constructor or destructor.
Constructor Initialization Section (InitSect)
Use the constructors initialization section to initialize your members.
Obvious Copyability (ObvCopy)
Make it obvious, if the class is intended to be copied. Forbid copying otherwise.
Copy and Assign Consistently (CopyAssign)
Declare copy and assignment operators consistently – either both, or none.
Related Rules
- CLSDESIGN:NoConv- No Implicit Conversions
- ERR:NoFail - Which Functions Never Fail
- VIRTUAL:RightDestr - Right Destructor
- VIRTUAL:SafeCopy - Safe Copying