dang near the same thing in C++