Previous | Code Standards | Next |
C++ source files shall end with the extension .cpp not .cc or .cxx.
As with header files these should start with a header block similar to the one generated by KDevelop.
Include files shall be included in the same format as for header file e.g
//----------------------------------------------------------------------------- // QT Headers #include <qtlabel.h> //----------------------------------------------------------------------------- // KDE Headers #include <kcombobox.h> //----------------------------------------------------------------------------- // Project Headers #include "mymoney/mymoneyfile.h" #include "ksomethingdlg.h"
Methods should be implemented as such:
void KSomethingDlg::useString(void) { .. function body }
with the function body indented by one tab.
Flow control statements should preferably follow the Kernighan & Ritchie style as such:
while (something_is_true) { operate on something; }
although the following Allman style is acceptable:
while (something_is_true) { operate; }
It is also acceptable for one line body statements to omit the curly braces as such:
while (something_is_true) operate;
Local variables should not be prefixed by the m_ member prefix and should start with a prefix as discussed in the header file. For example:
QString qstringTemp;
or
char *pszTemp;
Each method should have a comment block preceeding it in a suitable format for other developers to see how the method works and what types of return and arguments it expects. It does not have to be kdoc compatable because kdoc only parses the header files. All kdoc comment blocks should be in the header files.
An example of a source file conforming to the above standards can be found here.
Previous | Code Standards | Next |