C++ memory overlapping