-
Notifications
You must be signed in to change notification settings - Fork 128
Classes and Structs
-
Class naming: always start with an upper case letter, example:
ADIOS, Transform, Transport
.-
Don't
class filedescriptor : public transport { ...
-
Do
class FileDescriptor : public Transport { ...
-
Don't
-
Class members naming member variables: use hungarian notation
m_
prefix followed an upper case letter: m_XMLConfig, m_Shape. This method enables easy autocomplete of members in many editors as it's encouraged by the clang-format. Member functions will have the same rules as regular functions (e.g. start with an upper case letter).-
Don't
class Transport { public: std::string Name;
-
Do
class Transport { public: std::string m_Name;
-
Don't
-
Structs: reserve structs for public member variables only, Structs should not have member functions, derived classes (inheritance), or private members. Structs will be initialized with an upper case letter and member variables won't use hungarian notation (
m_
) as in classes.-
Don't
struct Attribute { public: std::string m_Name; std::string m_Type; std::string m_Value; // Use a class instead void SetName( const std::string name ); }
-
Do
struct Attribute { std::string Name; std::string Type; std::string Value; }
-
Don't
-
Single header (.h) and source (.cpp) file per class: Example: class Transport must have Transport.h and Transport.cpp only, do not define several classes in the same file. Define structs in single header file, ( e.g. Attribute in Attribute.h ). Exceptions:
- Templates
- Nested structs (only used a few times)
-
enum
class