C++
Review for Test 1: List of Topics Covered
This is a list of topics intended as a checklist to help you recall
what topics have been covered, both in lecture class and in the textbook.
General Computer and Programming Concepts
- Components (CPU, RAM, disk storage, I/O devices)
- bits and bytes
- evolution of programming languages
- interpreted vs. compiled languages
- Steps involved in software development
- Creation of a C++ program (source code, preprocessing, compilation,
linking, execution)
- syntax vs semantics
C++ Basics
General structure
- sequence of statements
- Can consist of multiple code files and libraries
- A program starts with main()
- Types of statements (including compound statements)
- Pre-compiled libraries, #include
Atomic Data Types
- integer types -- char, short, int, long
- signed and unsigned versions
- floating point types -- float, double, long double
- bool
- system dependent sizes (but common sizes currently in use today were
discussed)
Declaring and Intializing Variables
- naming rules for identifiers
- declaration format
- difference between declaring and initializing
- how to initialize built-in variable types with values
- Declaring variables with const (constants)
- "Declare before use" rule
Literals:
- integer, floating-point, character, string
- Escape sequences for special characters
- used for writing character literals, and used in string literals
- Know the common ones
Comments:
- // Line comments
- /* Block-style coments */
Input and Output with Streams
- objects cin, cout, cerr
- ostream and istream
- Library <iostream>
- insertion and extraction operators << and >>
- Know which operator used with which objects (cout, cin, etc)
- Know what can be used on the right side of each operator
- Cascading the << and >> operators
- Special formatting calls for floating-point numbers
- Fixed format vs. scientific format
- showpoint flag
- setting decimal precision
- Know how to set each of these
- namespace "std" (and using statements)
Operators:
- General Concepts
- operators and operands
- Arity (unary, binary, ternary)
- Precedence and associativity
- Cascading
- Arithmetic operators: + - / * %
- understand int vs. floating-point division (/ and %)
- increment and decrement: ++ --
- Post-increment vs. Pre-increment: x++ vs. ++x
- Post-decrement vs. Pre-decrement: x-- vs. --x
- assignment operator: =(single equal sign)
- Understand the concept of L-value vs R-value
- Other shortcut operators: += -= *= /= %=
- automatic type conversions
- using static_cast for explicit type-conversion
- Logical operators: == != < <= > >=
- Boolean operators: && (AND), || (OR), !
(NOT)
- short-circuit evaluation of && and ||
Control Structures
- Flow of Control concepts:
- sqeuential
- Selection (branching)
- Repetition (looping)
- The if/else selection statement
- Syntax format and rules for if and for if/else
statements
- How the test expression is evaluated
- Syntax vs. readability conventions (indentation, etc)
- Know when to use a block
- The switch selection statement
- Keywords switch, case, default,
break
- Understand how switch blocks work
- only works with integer and character expressions
- know when to use break
- Conditional operator
- Special operator that acts similar to if-statements
- Three operands (ternary operator)
- Operator consists of three parts, separated by symbols: ? :
- Example: x = (y < 0 ? 5 : 10);
- while and do-while loops
- Syntax format and rules for both
- How the test expression is evaluated
- Know the difference between while and do-while
- Know when to use a block
- Know when the loop repeats and when it quits
- for loops
- Three parts to the header: initial condition, test expression,
iterative expression
- Good for counting-controlled loops
- scope of loop control variable (if declared inside header)
- Special statements affecting loop control
Functions
Function Basics
- Know what a function is
- Reasons for writing functions (divide-and-conquer, reusability)
- Perspective: builder vs. caller
Using Functions
- Know how to call a function
- syntax
- passing arguments
- using the returned value
- Understand how they are like mathematical functions
- Declare-before-use policy
- Predefined functions
- Functions in libraries
- Know how to use #include to include them in a program
Building Functions
- Declaration -- name, return type, parameter list
- Know the format
- Know what to specify in the parameter list
- Definition -- header, along with function body
- the keyword return -- returning values from functions
- using the formal parameters in the function
- Scope (and how it relates to functions)
- Meaning of scope
- Global scope
- Variables local to function blocks
- Scope of function parameters
- void as a return type
- Empty parameter lists
Other Function Topics
- Function overloading - functions with same name and different
parameter lists
- Default parameters (new C++ feature, not available in C)
- optional parameters, by giving them default values
- Must be last in the parameter list
- Understand how default parameters on functions affects function
overloading
- Random number generation (using library functions)