you could also export the variable to the system env, or export to a tmp file, of if in windows, you could use the registry, though using registry could potentially be dangerous...
Personally, I would export to the system env.,.. There is a function to do so in C++ i do beleive... Dunno how standard it is though. You'll have to look it up.
If you no longer need the shared memory, you need to explicitly delete it, as it will persist even when both processes have terminated:
shared_memory_object::remove("yourSHMName");
Of course, you can have more than just one shared int, this works for structures and arrays as well, as long as they're trivially copyable.
If you want to use standard containers or other classes that support custom memory allocators, you can use boost's managed shared memory.