Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Hungarian Notation

Charles Simonyi is credited with first discussing Hungarian Notation. It is a variable naming convention that includes C++ information about the variable in its name (such as data type, whether it is a reference variable or a constant variable, etc). Every company and programmer seems to have their own flavor of Hungarian Notation. The following is just what we thought seemed easy for beginning students to understand.
Prefix b c str si i li f d ld sz if is of os S C boolean character C++ String short integer integer long integer floating point double-precision floating point Old-Style Null Terminated String Input File Stream Input Stream Output File Stream Output Stream declaring a struct declaring a class Type bool bStillGoing; char cLetterGrade; string strFirstName; short siChairs; int iCars; long liStars; float fPercent; double dMiles; char szName[NAME_LEN]; ifstream ifNameFile; void fct(istream &risIn); ofstream ofNameFile; void fct(ostream &rosIn); struct SPoint { class CPerson { SPoint pointLeft; SPoint ptLeft; // or abbrev. (be consistent) CPerson personFound; CPerson perFound; // or abbrev. (be consistent) Example

long double-precision floating point long double ldLightYears;

struct name or abbrev declaring an instance of a struct class name or abbrev declaring an instance of a class

The following table contains letters that go before the above prefixes.
Pre-prefix u k r s rg m_ p prg unsigned constant formal parameter reference formal parameter static array (stands for range) pointer to a single thing dynamically allocated array Type Example unsigned short usiStudents; void fct(const long kliGalaxies) void fct(long &rliGalaxies) static char scChoice; float rgfTemp[MAX_TEMP]; char *pcGrade; char *prgcGrades;

member variable of a struct or class char m_cLetterGrade;

You might also like