Introduce terms like declaration, initialization, and operand that often appear in C++ error messages so that students are prepared to understand and interpret the error messages they come across using C++.

  • Students often find compiler messages overwhelming and unhelpful.
    • If we provide students with the vocabulary they need to understand these error messages, we can help students learn to use compiler messages to debug their code.
  • The following vocabulary appears frequently in error messages:
    • operand
    • declaration
    • identifier
    • binary expression
    • specific types (like double, int etc), as well as the word "type"
    • segmentation fault
    • expression
    • token
    • preprocessing directive
  • Activity:
    • Give students example code and error messages to see if they can decode what the error messages are trying to say.
    • Ask students:
      • What does this error message mean?
      • What did the compiler think you were trying to express?
      • Based upon this error, what inferences can we make about what the compiler is expecting?
        • In Example 1 below we can infer that identifiers/variables don’t have spaces in them.
    • Here are two example error messages you can use:
      • Example 1: Sample compiler error of invalid operands passed to cout
      • Example 2: Sample compiler error expecting a semi-colon after a declaration

More about this tip

External Source

Interview with Katie Cunningham.