L2_var_types - Basic C Types Basic and Library Types For...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Basic and Library Types For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Piyush Kumar Basic C++ Types | integer data-types : char, short, int, long, unsigned char, unsigned short,… | floating point data-types : float, double, long double | logical data-type : bool z bool constants : true, false | character data-type : char and wchar_t z Char constants in single quotes : ’a’ | text data-type : string string constants in double quotes : ”Hello world” Basic C++ Types | void z Return type for a function with no return value z void pointers | unsigned and signed integers z unsigned char x = -1; ? z unsigned short int x = -1; ? 0 255 -1 254 -2 Wrap around effect. Machine dependent. Recommended assignments: 2.4/2.7/2.8/2.9 Basic Arithmetic types 10 19 3.4x10 4932 3.4x10 -4932 long double 8 15 1.7x10 308 1.7x10 -308 double 4 7 3.4x10 38 3.4x10 -38 float 4 - 2147483647 -2147483648 long 4 - 2147483647 -2147483648 int 2 - 32767 -32768 short 1 - 127 -128 char Bytes Digits of Precision High Low Type Variable Naming | Read about hungarian naming: | http://en.wikipedia.org/wiki/Hungarian_notati on | http://www.idleloop.com/hungarian/hungaria n.html | http://www.totse.com/en/technology/comput er_technology/hungnote.html | Use them in your next assignment onwards. Hungarian naming | Three parts z Base Type z One or more prefixes z Qualifier
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Hungarian Base Types | Specifies the type of the variable being named | Not for predefined types | Example: z wn = Window z scr = Screen z fon = Font z pa = Paragraph | Example: z WN wnMain=NULL; z FONT fonUserSelected = TIMES_NEW_ROMAN; Prefixes | Go in front of the base type | Somewhat standard list: z a = Array z c = Count z d = Difference z e = Element of an array z g = Global variable z h = Handle z i = index to array z m = Module-level variable z p(np, lp) = Pointer (near or long) | Describes how the variable will be used. | Examples z Array of windows: awnDialogs z Handle to a window: hwnMyWindow z Number of fonts: cfon Qualifiers | The rest of the variable name in case you were not using Hungarian naming. More Examples
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/27/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 6

L2_var_types - Basic C Types Basic and Library Types For...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online