Professional Documents
Culture Documents
A header file contains the declarations of constants, data types, variables, and forward (early) declarations of functions. A stream is a sequence of data flowing from one part of a computer to another. Day 2: C++ Program Components The predefined data types in Borland C++ 4.0 Naming items in Borland C++ 4.0T The #include directive Declaring variables Declaring constants Declaring and prototyping functions Local variables in functions Static variables in functions Inline functions Exiting functions Default arguments Function overloading
Declaring Constants Constants are identifiers that are associated with fixed values.C++ offers constants in two varieties: macro-based and formal. The macro-based constants are inherited from C and use the #define compiler directive.
Inline Functions
Function Overloading
This new feature enables you to declare multiple functions that have the same name but different parameter lists. A parameter list is also called the function signature.
Increment Operators
Increment (++) and decrement (--) operators enable you to increment and decrement, respectively, by 1 the value stored in a variable.
Assignment Operators
Typecasting
Typecasting is a language feature that enables you to specify explicitly how to convert a value from its original data type into a compatible data type. Thus, typecasting instructs the compiler to perform the conversion you want and not the one the compiler thinks is needed.
does not support predefined Boolean identifiers. Instead, the language regards 0 as false and a nonzero value as true. variable = (condition) ? expression1 : expression2;
Boolean Expressions
Bit-Manipulation Operators : &,|,^,~,<<,>>
Bit-manipulating operators toggle, set, query, and shift the bits of a byte or a word
Structures
Structures enable you to define a new type that logically groups several fields or members.
Unions
Unions are special structures that store members that are mutually exclusive
Reference Variables
Like reference parameters, reference variables become aliases to the variables they access.
Overview of Pointers
An address is a memory location. A tag is the variables name A pointer is a special variable that stores the address of another variable or information. Pointers to Existing Variables
Pointers to Arrays A program variable is a label that tags a memory address. Using a variable in a program means accessing the associated memory location by specifying its name (or tag, if you prefer). In this sense, a variable becomes a name that points to a memory locationa pointer
Far Pointers
Within a segment you can use near pointers to access data in the same segment. The pointers only store the offset address in the segment and thus require fewer bytes to store their address. By contrast,far pointers store the segment and offset addresses, and thus they require more space. Windows applications use far pointers.