Cpp Coding Standards
This page gathers rules, advice and best practices for developing with C++ in the OpenOffice.org project.
Contents
Class Design
General hints for class design. Items referring to constructors, destructors, copying and allocation (of classes) reside in topic “Class Initialization”. Items referring to virtual classes in hierarchies reside in “Hierarchies of Virtual Classes”. Encapsulation related items are in topic “Encapsulation”.
OneResponsibility
Give one class only one cohesive responsibility.
Inherit
Inherit to be reused, not to reuse. Else prefer composition over inheritance.
NoImplicitConversions
Make single argument constructors “explicit”. Be aware of default arguments. Do not provide operator TYPE() functions.
SpecificNewDelete
When you provide a class-specific new or delete with custom parameters, provide the corresponding new or delete as well. (Not doing this causes memory leaks.) If you provide one class specific new, this hides all other variants of new. So you probably want to provide also the three all of the standard forms of new (plain, nothrow and inplace).
Class Construction, Destruction and Copying