Skip to content

Latest commit

 

History

History
59 lines (50 loc) · 1.79 KB

Naming_C++.md

File metadata and controls

59 lines (50 loc) · 1.79 KB

Naming Conventions - C++

Pascal Case Camel Case Snake Case Lower Case Caps Case
LazyDogBrownFox lazyDogBrownFox lazy_dog_brown_fox lazydogbrownfox LAZYDOGBROWNFOX

Files

  • Snake Case.
my_useful_class.c
my_useful_class.cpp

Classes and Types

  • Pascal Case: The names of all types — classes, structs, type aliases, enums, and type template parameters — have the same naming convention. No underscores.
class CirclePlotter : public PlotterClass{};
struct MyStruct{};

Funcitons/Methods

  • Pascal Case. The same naming rule applies to class- and namespace-scope constants that are exposed as part of an API and that are intended to look like functions
  • Accessors and mutators (get and set functions) may be named like variables
int RandomFunctionGenerator();
void set_count(int count);

Variables

  • Lower Case or Snake Case for multiple words.
  • Data members of classes (but not structs) additionally have trailing underscores
std::string table_name;
int count=0;
class TableInfo {
  ...
 private:
  std::string table_name_;  // OK - underscore at end.
  static Pool<TableInfo>* pool_; 
};

Namespaces

  • Lower Case or Snake Case for multiple words.
example::example_scope::example_item temp_example;

Macros

  • All Caps Case with underscores separating words.
#define PI 3.14159265358979323;

Reference

For more standards and links refer to Coding Standards Lookup page.

Guidelines

To contribute refer to the Contributing and License pages.