| 263 | |
| 264 | |
| 265 | == Other Punctuation == |
| 266 | |
| 267 | * Constructors for C++ classes should initialize all of their members using C++ constructor synatax. Each member (and superclass) should be indented on a separate line, with the colon or comma preceding the member on that line. |
| 268 | |
| 269 | '''Right:''' |
| 270 | {{{ |
| 271 | #!cpp |
| 272 | MyClass::MyClass(Document* doc) |
| 273 | : MySuperClass() |
| 274 | , m_myMember(0) |
| 275 | , m_doc(doc) |
| 276 | { |
| 277 | } |
| 278 | |
| 279 | MyOtherClass::MyOtherClass() |
| 280 | : MySuperClass() |
| 281 | { |
| 282 | } |
| 283 | }}} |
| 284 | |
| 285 | '''Wrong:''' |
| 286 | {{{ |
| 287 | #!cpp |
| 288 | MyClass::MyClass(Document* doc) : MySuperClass() |
| 289 | { |
| 290 | m_myMember = 0; |
| 291 | m_doc = doc; |
| 292 | } |
| 293 | |
| 294 | MyOtherClass::MyOtherClass() : MySuperClass() {} |
| 295 | }}} |
| 296 | |
| 297 | * Pointer types in non-C++ code — Pointer types should be written with a space between the type and the * (so the * is adjacent to the following identifier if any). |
| 298 | |
| 299 | * Pointer and reference types in C++ code — Both pointer types and reference types should be written with no space between the type name and the * or &. |
| 300 | |
| 301 | '''Right:''' |
| 302 | {{{ |
| 303 | #!cpp |
| 304 | Image* SVGStyledElement::doSomething(PaintInfo& paintInfo) |
| 305 | { |
| 306 | SVGStyledElement* element = static_cast<SVGStyledElement*>(node()); |
| 307 | const KCDashArray& dashes = dashArray(); |
| 308 | }}} |
| 309 | |
| 310 | '''Wrong:''' |
| 311 | {{{ |
| 312 | #!cpp |
| 313 | Image *SVGStyledElement::doSomething(PaintInfo &paintInfo) |
| 314 | { |
| 315 | SVGStyledElement *element = static_cast<SVGStyledElement *>(node()); |
| 316 | const KCDashArray &dashes = dashArray(); |
| 317 | }}} |
| 318 | |
| 319 | |
| 320 | == Include Statements == |
| 321 | |
| 322 | * All files must #include "config.h" first. |
| 323 | |
| 324 | * All files must #include the primary header second, just after "config.h". So for example, Node.cpp should include Node.h first, before other files. This guarantees that each header's completeness is tested, to make sure it can be compiled without requiring any other header files be included first. |
| 325 | |
| 326 | * Other #include statements should be in sorted order (case sensitive, as done by the command-line sort tool or the Xcode sort selection command). Don't bother to organize them in a logical order. |