Basic Building Blocks

3 class hours

Basic Building Blocks

Types

  • A type is the name of the set of all possible values that an expression might have
  • As of now, the types we will use in our language are
    • int
    • double
    • char
    • bool
    • cp::string

Slides

Memory Model - Part 1

  • This is a very simplified view of how a computer running a C++ program manages memory.
  • Basic functions: store and retrieve.
  • The resulting value of an expression is stored in a memory location that can be retrieved using its name.

Slides

Variables and Constants

  • A variable is the name of a location that stores a value of a particular type
    • Has a value and a type
  • Not the same as a math variable
  • Declaration and Initialisation
  • Constant: a variable whose value does not change

Slides

Operators, Expressions, Statements

  • Operator: To simplify writing certain expressions (e.g., +, -)
  • Expression: A meaningful program fragment
  • Statement: The smallest unit of execution. A simple statement must end with a semicolon.

Slides

Previous
Next