Theory And Algorithms For Simulating Multibody Dynamic Systems Using Modern C++