Joshua's Docs - C++ Assorted Notes, Cheatsheet, Etc.
Light

C++ Formatting, File Organization, and Styles

Very extensive guide: Google's C++ Style Guide

C++ File Inclusion and Sharing

Header Guard Pattern

In order to prevent duplicate inclusions, it is recommended to adopt the "header guard pattern" (also called "define guard"). It looks something like this:

my_class.h:

#ifndef MY_CLASS
#define MY_CLASS
// ...
#endif // MY_CLASS

The comment at the end is not part of the macro, nor necessary, but is helpful as a reminder of "here is the end of our define block for {x}!"

Markdown Source Last Updated:
Mon May 25 2020 15:47:56 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Fri May 22 2020 22:28:59 GMT+0000 (Coordinated Universal Time)
© 2024 Joshua Tzucker, Built with Gatsby
Feedback