instead of writing it once in C++