How exactly would this look, if implemented in C++? Similarly, how would this look in Java?