Build program by command:$ g++ $(pkg-config --libs --cflags opencv) -o Sample Sample.cpp
Run program by $ ./Sample
Live camera window should show on screen

Another project can be checked at /usr/local/share/OpenCV/samples/cppFace detection project:
Build face detect project facedetect.cpp, run it with command:./facedetect --cascade="/home/pi/opencv/opencv-3.2.0/data/haarcascades/haarcascade_frontalface_alt.xml"
Result video of face detection