See the C/C++ API documentation:
You can basically write your C++ code as a mex function (it operates like an m-file function callable from MATLAB) which can itself call back into MATLAB via the mexCallMATLAB function.
Or you can write a C++ program that calls into what is called a MATLAB Engine, which is a separate process from your C++ program so it requires copying all data into and out of the Engine (you can often avoid this copying with the mex function approach above)
