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

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m (formatting)
Line 1: Line 1:
Topic-Id: '''CLSINIT'''
+
=== Class Construction, Destruction and Copying (CLSINIT) - Summary ===
 +
''Special issues of constructors, copying and destructors.''
  
Special issues of constructors, copying and destructors.
+
===== No Virtual Calls in Constructor or Destructor <span id="NoVirt">(NoVirt)</span> =====
----
+
Don't call your own class' virtual functions in a constructor or destructor.  [[/NoVirt|Details >]]
=== Summary ===
+
  
==== No Virtual Calls in Constructor or Destructor <span id="NoVirt">(NoVirt)</span> ====
+
===== Constructor Initialization Section <span id="InitSect">(InitSect)</span> =====
Don't call your own class' virtual functions in a constructor or destructor.  
+
Use the constructors initialization section to initialize your members. [[/InitSect|Details >]]
  
[[/NoVirt|Details]]
+
===== Obvious Copyability <span id="ObvCopy">(ObvCopy)</span> =====
==== Constructor Initialization Section <span id="InitSect">(InitSect)</span> ====
+
Make it obvious, if the class is intended to be copied. Forbid copying otherwise. [[/ObvCopy|Details >]]
Use the constructors initialization section to initialize your members.
+
  
[[/InitSect|Details]]
+
===== Copy and Assign Consistently <span id="CopyAssign">(CopyAssign)</span> =====
==== Obvious Copyability <span id="ObvCopy">(ObvCopy)</span> ====
+
Declare copy and assignment operators consistently – either both, or none. [[/CopyAssign|Details >]]
Make it obvious, if the class is intended to be copied. Forbid copying otherwise.
+
  
[[/ObvCopy|Details]]
 
==== Copy and Assign Consistently <span id="CopyAssign">(CopyAssign)</span> ====
 
Declare copy and assignment operators consistently – either both, or none.
 
 
[[/CopyAssign|Details]]
 
 
----
 
----
 
=== Related Rules ===
 
=== Related Rules ===

Revision as of 14:06, 12 April 2007

Class Construction, Destruction and Copying (CLSINIT) - Summary

Special issues of constructors, copying and destructors.

No Virtual Calls in Constructor or Destructor (NoVirt)

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

Constructor Initialization Section (InitSect)

Use the constructors initialization section to initialize your members. Details >

Obvious Copyability (ObvCopy)

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

Copy and Assign Consistently (CopyAssign)

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


Related Rules


Personal tools