-
Notifications
You must be signed in to change notification settings - Fork 128
Classes and Structs
williamfgc edited this page May 1, 2017
·
7 revisions
-
Naming: Classes will be initialized with an upper case letter, example: ( ADIOS, NETCDF, PHDF5, Transform, Transport, etc. ).
-
Don't
class filedescriptor : public transport {...
-
Do
class FileDescriptor : public Transport {...
-
-
Members: Class member variables will 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. While 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;
-
-
Structs: reserve structs for public member variables only, Structs should not have member functions, inheritance or private members. Structs will be initialized with an upper case letter and member variables won't use hungarian notation as classes.
-
Don't
struct Attribute { public: std::string m_Name; std::string m_Type; std::string m_Value; void SetName( const std::string name ); // Use a class instead }
-
Do
struct Attribute { std::string Name; std::string Type; std::string Value; }
-
- Class Header and Source Files: Only allow one header and one source file per class ( e.g. class Transport in Transport.h and Transport.cpp), do not define several classes in the same file. Structs are always define in one header file, ( e.g. Attribute in Attribute.h )