Microsoft Visual C++ Windows Applications by Example
上QQ阅读APP看书,第一时间看更新

Summary

Let's revise the points quickly in brief as discussed in this chapter:

  • The text of a program is called its source code. It is translated into target code by the compiler. The target code is then linked to target code of other programs, finally resulting in executable code.
  • The basic types of C++ can be divided into the integral types char, short int, int, and long int, and the floating types float, double, and long double. The integral types can also be signed or unsigned.
  • Values of a type can be organized into an array, which is indexed by an integer. The first index is always zero. An enum value is an enumeration of named values. It is also possible to define new types with typedef, though that feature should be used carefully.
  • A pointer holds the memory address of another value. There are operators to obtain the value pointed at and to obtain the address of a value. A reference is a simpler version of a pointer. A reference always holds the address of a specific value while a pointer may point at different values. A pointer can also be used to allocate memory dynamically; that is, during the program execution.
  • The operators can be divided into the arithmetic operators addition, subraction, multiplication, division, and modulo; the relational operators equal to, not equal to, less than, less than or equal to, greater than, and greater than or equal to; the logical operators not, and, and or; the bitwise operators inverse, and, or, and xor; the assignment operators, and the condition operator. There is also the operator sizeof, which gives the size in bytes of values of a certain type.
  • The statments of C++ can divided into the selection statements if and switch, the iteration statements while and for, and the jump statements break, continue, and goto, even thought goto should be avoided.
  • A function may take one or more formal parameters as input. When it is called, a matching list of actual parameters must be provided. A function may also return a value of arbitrary type, with the exception of array. Two functions may be overloaded, which means they have the same name, as long as they differ in their parameter lists. A function may call itself, directly or indirectly; this is called recursion. A function can also have default parameters, which means that if the caller does not provide enough parameters, the missing parameters will be given the default values.
  • A macro is a textual substitution performed by the preprocessor before the compilation of the program. Similar to functions, they may take parameters. We can also include the text of other files into our program. Finally, we can include and exclude certain parts of the code by conditional programming.