Editing C++ style guide
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 169: | Line 169: | ||
=== Namespace === | === Namespace === | ||
All code should be in the | All code should be in the octave namespace. This is an ongoing project. We | ||
are still moving existing classes into namespaces but all new classes | |||
should go somewhere into the "octave" namespace. There is 1 extra level for namespaces | |||
inside octave to be used with care, we don't want too many namespaces. | |||
Ask before creating a new namespace. | |||
* Indent namespaces as any other block. Emacs and other editors can do this automatically. | |||
* Define namespace on the .cc files; | |||
* Do not use "using X" directives; | |||
* Do not declare anything on the std namespace; | |||
{{Code|namespace style on a .h file|<syntaxhighlight lang="cpp"> | |||
// Note indentation | |||
{{Code| | namespace octave | ||
{ | |||
namespace math | |||
{ | |||
class foo | |||
{ | |||
public: | |||
foo (...); | |||
}; | |||
} | |||
} | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
{{Code|namespace style on a .cc file|<syntaxhighlight lang="cpp"> | |||
// Note indentation and that functions are not defined | |||
{{Code| | // as "octave::math::foo:foo" | ||
// Note indentation and that functions are not defined as "octave::math::foo:foo" | |||
namespace octave | namespace octave | ||
{ | { | ||
Line 203: | Line 209: | ||
} | } | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
== Naming == | == Naming == |