Writing functions in C++