The program itself looks fine. I would suggest that there is some kind of quirk in your compilation environment that causes segfault.
It is best to run this in the debugger (gdb) - this will tell you where it is crashing, which will help you figure out what the problem is.
To do this, do the following compilations:
g++ -g -o hello hello.cpp
then run gdb:
gdb hello
and in the gdb type prompt
run
. ,
bt
, , , , .