Modeling three body problem in C++