I hope you didn't try to chmod a.out on FAt32 or NTFS file system, do you ? Because it will not work that way.
Copy the file to your home directory, chmod 755 and try again (assuming your /home/username partition is mounted with execute permissions - usually it is)
And anyway g++ should make the file already executable for you (if you are in ext4 file system at least).