This type of question has been asked multiple times, please use the search feature. One such topic is here (ignore the PROS code, look towards the end)
check the documentaion
write some blocks code and then study the generated C++ in the code browser, use that as a starting point.