Difference between revisions of "Cpp Coding Standards/Class Construction, Destruction and Copying"
From Apache OpenOffice Wiki
Line 1: | Line 1: | ||
+ | == Class Construction, Destruction and Copying == | ||
Special issues of constructors, copying and destructors. | Special issues of constructors, copying and destructors. | ||
− | + | ---- | |
+ | === Rules === | ||
==== NoVirtualsInCtorDtor ==== | ==== NoVirtualsInCtorDtor ==== | ||
Don't call your own class' virtual functions in a constructor or destructor. | Don't call your own class' virtual functions in a constructor or destructor. | ||
Line 12: | Line 14: | ||
==== CopyAndAssignConsistently ==== | ==== CopyAndAssignConsistently ==== | ||
Declare copy and assignment operators consistently – either both, or none. | Declare copy and assignment operators consistently – either both, or none. | ||
+ | ---- | ||
+ | === Related Rules === | ||
+ | * [[../CLSDESIGN#NoImplicitConversions | CLSDESIGN:NoImplicitConversions]] | ||
+ | * [[../ERR#NeverFails | ERR:NeverFails]] | ||
+ | * [[../HIERARCHY#RightDestructor | HIERARCHY:RightDestructor]] | ||
+ | * [[../HIERARCHY#SafeCopying | HIERARCHY:SafeCopying]] | ||
---- | ---- | ||
[[Category:Coding Standards]] | [[Category:Coding Standards]] |
Revision as of 11:10, 27 November 2006
Contents
Class Construction, Destruction and Copying
Special issues of constructors, copying and destructors.
Rules
NoVirtualsInCtorDtor
Don't call your own class' virtual functions in a constructor or destructor.
CtorInitSection
Use the constructors initialization section to initialize your members.
ObviousCopyability
Make it obvious if the class is intended to be copied. Forbid copying otherwise.
CopyAndAssignConsistently
Declare copy and assignment operators consistently – either both, or none.