
- •Introduction
- •Terminology
- •Source Code in Files Code Structure
- •Naming Files
- •Comments
- •Include Files
- •Assigning Names
- •Style Classes
- •Functions
- •Compound Statements
- •Flow Control Statements
- •Pointers and References
- •Miscellaneous
- •Classes Considerations Regarding Access Rights
- •Inline Functions
- •Friends
- •Const Member Functions
- •Constructors and Destructors
- •Assignment Operators
- •Operator Overloading
- •Member Function Return Types
- •Inheritance
- •Templates
- •Functions
- •Function Arguments
- •Function Overloading
- •Return Types and Values
- •Inline Functions
- •Temporary Objects
- •General
- •Constants
- •Variables
- •Pointers and References
- •Type Conversions
- •Flow Control Structures
- •Expressions
- •Memory Allocation
- •Fault Handling
- •Portable Code Localization
- •Data Abstraction
- •Sizes of Types
- •Type Conversions
- •Data Representation
- •Underflow/Overflow
- •Order of Execution
- •Temporary Objects
- •Pointer Arithmetic
- •References
- •Appendix a. Hungarian Notation
- •C. Examples
References
B. Stroustrup, M. Ellis. The Annotated C++ Reference Manual. Addison Wesley, 1990.
C. Kindel. The Rules of the Component Object Model. MSDN Library, Technical Articles, 1995.
MFC: Using the MFC Source Files. MSDN Library, Programming with MFC: Encyclopedia.
Exception Handling Topics (C++). MS Visual C++ Documentation, 1997.
C. Vu, S. Satoh, and M. Grove. Multibyte Character Set (MBCS) Survival Guide. MSDN Library, Backgrounders, 1995.
Appendix a. Hungarian Notation
The following table shows a subset of Hungarian notation used in MS Visual C++ and its class libraries: For each type of variable a character is given to represent it.
Prefix |
Type |
Description |
Example |
ch |
char |
8-bit character |
chGrade |
ch |
TCHAR |
16-bit character if _UNICODEis defined |
chName |
b |
BOOL, bool |
Boolean value |
bEnabled |
n |
int |
Integer (size dependent on operating system) |
nLength |
n |
UINT |
Unsigned value (size dependent on operating system) |
nLength |
w |
WORD |
16-bit unsigned value |
wPos |
l |
LONG |
32-bit signed integer |
lOffset |
dw |
DWORD |
32-bit unsigned integer |
dwRange |
by |
BYTE |
8-bit unsigned value |
byBuf |
flt |
float |
Float value |
fltPos |
dbl |
double |
Double value |
dblPos |
x, y |
coordinates |
Device coordinates |
xMouse |
p |
* |
Pointer |
pDoc |
psz, lpsz |
LPSTR, LPCSTR |
32-bit pointer to (constant) character string |
pszName |
psz, lpsz |
LPTSTR, LPCTSTR |
32-bit pointer to (constant) character string if _UNICODEis defined |
pszName |
h |
handle |
Handle to Windows object |
hWnd |
pfn, lpfn |
callback |
Pointer to function |
pfnAbort |
rc |
RECT |
Rectangle |
rcClient |
pt |
POINT |
Point |
ptMouse |
size |
SIZE |
Size |
sizeMin |
rg |
range |
Array of objects |
rgPoints |
Various prefixes may combine to represent a complicated type of variable. For example, use ‘pdw’ to specify a pointer to a DWORD.
B. MS Visual C++ Resource Prefixes
Symbols generated and used by AppWizard and ClassWizard in MFC and ATL applications are listed below. You can also use these prefixes in classes and resource files in your MFC (ATL)-friendly classes.
Prefix |
Type of Symbol |
Example |
Range |
IDR_ |
Identification shared by multiple resources of different types |
IDR_MAINFRAME |
1 to 0x6FFF |
IDD_ |
Dialog resource |
IDD_SPELL_CHECK |
1 to 0x6FFF |
HIDD_ |
Dialog-resource Help context |
HIDD_SPELL_CHECK |
0x20001 to 0x26FF |
IDB_ |
Bitmap resource |
IDB_COMPANY_LOGO |
1 to 0x6FFF |
IDC_ |
Cursor resource |
IDC_PENCIL |
1 to 0x6FFF |
IDI_ |
Icon resource |
IDI_NOTEPAD |
1 to 0x6FFF |
ID_ _ |
Command from menu item or toolbar |
ID_TOOLS_SPELLING |
0x8000 to 0xDFFF |
HID_ |
Command Help context |
HID_TOOLS_SPELLING |
0x18000 to 0x1DFFF |
IDP_ |
Message-box prompt |
IDP_INVALID_PARTNO |
8 to 0xDFFF |
HIDP_ |
Message-box Help context |
HIDP_INVALID_PARTNO |
0x30008 to 0x3DFFF |
IDS_ |
String resource |
IDS_COPYRIGHT |
1 to 0x7FFF |
IDC_ |
Control within dialog box |
IDC_RECALC |
8 to 0xDFFF |