C++ Errors

When you write programs, you encounter multiple errors, warnings.

Types of errors

  • Compiler errors
  • Run time errors
  • Warnings

Compiler errors

These errors are reported by compiler during compile time, if you don’t adhere to the syntax rules defined by the language (compiler).

Below is an example where we forgotten to put semicolon at the end of the statement.

If you compile this program, IDE will show compiler errors, something like below : [the below error is from CodeLite IDE]

Run time errors

These are not detected at compile time, but the program doesn’t work as expected. These are also called logical errors.

Example : Division by zero, null pointer accessing, etc

Check below example : [compile time error is resolved by putting semicolon at the end]

It doesn’t print the variable value.