lab2 to c++