Finished translating to c++.