Add cpp file for calculating distance