Error messages have three parts: file location, error type, and explanation. A message like main.cpp:5:12: error: expected ; means line 5 has a missing semicolon. The compiler often reports errors on the line after the actual mistake.
If line 5 says missing semicolon, check line 4. Fix the first error and recompile. One mistake can cause ten error messages. Many disappear after you fix the first one.