Difference between revisions of "Cpp Coding Standards/Class Construction, Destruction and Copying"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 1: Line 1:
== Class Construction, Destruction and Copying ==
+
Topic-Id: '''CLSINIT'''
 +
 
 
Special issues of constructors, copying and destructors.
 
Special issues of constructors, copying and destructors.
 
----
 
----
 
=== Summary ===
 
=== Summary ===
==== NoVirtualsInCtorDtor ====
+
==== No Virtuals in Constructor or Destructor ====
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.  
  
==== CtorInitSection ====
+
[[/NoVirt|Details]]
 +
 
 +
==== Constructor Initialization Section ====
 
Use the constructors initialization section to initialize your members.
 
Use the constructors initialization section to initialize your members.
  
==== ObviousCopyability ====
+
[[/InitSect|Details]]
 +
==== Obvious Copyability ====
 
Make it obvious if the class is intended to be copied. Forbid copying otherwise.
 
Make it obvious if the class is intended to be copied. Forbid copying otherwise.
  
==== CopyAndAssignConsistently ====
+
[[/ObvCopy|Details]]
 +
 
 +
==== Copy and Assign Consistently ====
 
Declare copy and assignment operators consistently – either both, or none.
 
Declare copy and assignment operators consistently – either both, or none.
 +
 +
[[/CopyAssign|Details]]
 +
 
----
 
----
 
=== Related Rules ===
 
=== Related Rules ===
* [[../CLSDESIGN#NoImplicitConversions | CLSDESIGN:NoImplicitConversions]]
+
* [[../Class Design#No Implicit Conversions| Class Design/No Implicit Conversions]]
* [[../ERR#NeverFails | ERR:NeverFails]]
+
* [[../Error Handling#Which Functions Never Fail|Error Handling/Which Functions Never Fail]]
* [[../HIERARCHY#RightDestructor | HIERARCHY:RightDestructor]]
+
* [[../Virtual Classes#Right Destructor|Virtual Classes/Right Destructor]]
* [[../HIERARCHY#SafeCopying | HIERARCHY:SafeCopying]]
+
* [[../Virtual Classes#Safe Copying|Virtual Classes/Safe Copying]]
----
+
=== Suggestions for Rules to Add or Remove ===
+
  
 
----
 
----
 
[[Category:Coding Standards]]
 
[[Category:Coding Standards]]

Revision as of 16:31, 28 November 2006

Topic-Id: CLSINIT

Special issues of constructors, copying and destructors.


Summary

No Virtuals in Constructor or Destructor

Don't call your own class' virtual functions in a constructor or destructor.

Details

Constructor Initialization Section

Use the constructors initialization section to initialize your members.

Details

Obvious Copyability

Make it obvious if the class is intended to be copied. Forbid copying otherwise.

Details

Copy and Assign Consistently

Declare copy and assignment operators consistently – either both, or none.

Details


Related Rules


Personal tools