You gave us the code, put it in code tags and stated the issue correctly - nobody can complain about that.
If you run the code in cpp.sh (little gear-wheel icon to top right of your code sample if it is runnable) then it will flag a lot of warnings/errors for you. You should be able to set various error-checking flags for your own compiler, too. (Though, that will vary from compiler to compiler).