This you can do by using the -std=c++11 flag. Here's an example:
g++ -std=c++11 -Wall -Wextra -Werror main.cpp -o main
Here
-Wall — enables all major warnings.
-Wextra — enables other important warnings.
-Werror — make all warnings into errors, causing compilations to fail if any warnings are reported.