NamingConventions.txtNamingConventions.txtNamingConventions.txtNamingConventions.txt
Naming Conventions for writting C++ programs.Naming Conventions for writting C++ programs.Naming Conventions for writting C++ programs.Naming Conventions for writting C++ programs.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new
types added to thetypes added to thetypes added to thetypes added to the
language, Hence the prefix T.language, Hence the prefix T.language, Hence the prefix T.language, Hence the prefix T.
e.g.e.g.e.g.e.g.
class TPointclass TPointclass TPointclass TPoint
{{{{
---;---;---;---;
---;---;---;---;
};};};};
2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each
word must begin withword must begin withword must begin withword must begin with
capital alphabet except first word;capital alphabet except first word;capital alphabet except first word;capital alphabet except first word;
e.g.e.g.e.g.e.g.
class TPersonclass TPersonclass TPersonclass TPerson
{{{{
private:private:private:private:
char _nameOfPerson[30];char _nameOfPerson[30];char _nameOfPerson[30];char _nameOfPerson[30];
int _age;int _age;int _age;int _age;
};};};};
3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet.
e.g.e.g.e.g.e.g.
class TShapeclass TShapeclass TShapeclass TShape
{{{{
public:public:public:public:
void AcceptRecord();void AcceptRecord();void AcceptRecord();void AcceptRecord();
void CalculateArea();void CalculateArea();void CalculateArea();void CalculateArea();
void CalculatePerimeter();void CalculatePerimeter();void CalculatePerimeter();void CalculatePerimeter();
};};};};
4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with
lowercase alphabetlowercase alphabetlowercase alphabetlowercase alphabet
e.ge.ge.ge.g
int countNumber;int countNumber;int countNumber;int countNumber;
5. All Global variable names must start with letter g;5. All Global variable names must start with letter g;5. All Global variable names must start with letter g;5. All Global variable names must start with letter g;
6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets;
e.g.e.g.e.g.e.g.
const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7;
7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e.
e.g.e.g.e.g.e.g.
enum EColorenum EColorenum EColorenum EColor
{{{{
eRed=1,eBlue,eWhiteeRed=1,eBlue,eWhiteeRed=1,eBlue,eWhiteeRed=1,eBlue,eWhite
};};};};
Page 1Page 1Page 1Page 1
NamingConventions.txtNamingConventions.txtNamingConventions.txtNamingConventions.txt
8. It is compulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing
curly brace.curly brace.curly brace.curly brace.
e.g.e.g.e.g.e.g.
class TPointclass TPointclass TPointclass TPoint
{{{{
};//end of class Tpoint};//end of class Tpoint};//end of class Tpoint};//end of class Tpoint
int main( void )int main( void )int main( void )int main( void )
{{{{
for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i )
{{{{
}//end of for loop}//end of for loop}//end of for loop}//end of for loop
return 0;return 0;return 0;return 0; //exit from main//exit from main//exit from main//exit from main
}//end of main function}//end of main function}//end of main function}//end of main function
Page 2Page 2Page 2Page 2

C++ Naming Conventions

  • 1.
    NamingConventions.txtNamingConventions.txtNamingConventions.txtNamingConventions.txt Naming Conventions forwritting C++ programs.Naming Conventions for writting C++ programs.Naming Conventions for writting C++ programs.Naming Conventions for writting C++ programs. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new1. All the class names must start with T.Classes behave like new types added to thetypes added to thetypes added to thetypes added to the language, Hence the prefix T.language, Hence the prefix T.language, Hence the prefix T.language, Hence the prefix T. e.g.e.g.e.g.e.g. class TPointclass TPointclass TPointclass TPoint {{{{ ---;---;---;---; ---;---;---;---; };};};}; 2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each2. Name of all data members must begin with _ (underscore) and each word must begin withword must begin withword must begin withword must begin with capital alphabet except first word;capital alphabet except first word;capital alphabet except first word;capital alphabet except first word; e.g.e.g.e.g.e.g. class TPersonclass TPersonclass TPersonclass TPerson {{{{ private:private:private:private: char _nameOfPerson[30];char _nameOfPerson[30];char _nameOfPerson[30];char _nameOfPerson[30]; int _age;int _age;int _age;int _age; };};};}; 3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet.3. Name of all member functions must begin with capital alphabet. e.g.e.g.e.g.e.g. class TShapeclass TShapeclass TShapeclass TShape {{{{ public:public:public:public: void AcceptRecord();void AcceptRecord();void AcceptRecord();void AcceptRecord(); void CalculateArea();void CalculateArea();void CalculateArea();void CalculateArea(); void CalculatePerimeter();void CalculatePerimeter();void CalculatePerimeter();void CalculatePerimeter(); };};};}; 4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with4. All local(automatic) variable names in functions must begin with lowercase alphabetlowercase alphabetlowercase alphabetlowercase alphabet e.ge.ge.ge.g int countNumber;int countNumber;int countNumber;int countNumber; 5. All Global variable names must start with letter g;5. All Global variable names must start with letter g;5. All Global variable names must start with letter g;5. All Global variable names must start with letter g; 6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets;6. All constants must be coded with uppercase alphabets; e.g.e.g.e.g.e.g. const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7;const unsigned DAYS_IN_WEEK = 7; 7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e.7. All enumerations ( enums ) must begin with E and members with e. e.g.e.g.e.g.e.g. enum EColorenum EColorenum EColorenum EColor {{{{ eRed=1,eBlue,eWhiteeRed=1,eBlue,eWhiteeRed=1,eBlue,eWhiteeRed=1,eBlue,eWhite };};};}; Page 1Page 1Page 1Page 1
  • 2.
    NamingConventions.txtNamingConventions.txtNamingConventions.txtNamingConventions.txt 8. It iscompulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing8. It is compulsory to write comments after each and every closing curly brace.curly brace.curly brace.curly brace. e.g.e.g.e.g.e.g. class TPointclass TPointclass TPointclass TPoint {{{{ };//end of class Tpoint};//end of class Tpoint};//end of class Tpoint};//end of class Tpoint int main( void )int main( void )int main( void )int main( void ) {{{{ for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i )for( int i = 0;i < 5; ++ i ) {{{{ }//end of for loop}//end of for loop}//end of for loop}//end of for loop return 0;return 0;return 0;return 0; //exit from main//exit from main//exit from main//exit from main }//end of main function}//end of main function}//end of main function}//end of main function Page 2Page 2Page 2Page 2