Added comments that try to explain what (and why) is going on in the example code
in main.cpp .