If you use O_CREAT variant, this is because you want the file to be created if non existing yet. Thus, in the case of creation it is requested that the file have permission bits set to some value (read, write, execute, etc). This is documented in man page of open:
O_CREAT
[...]
The mode argument specifies the file mode bits to be
applied when a new file is created.  If neither O_CREAT
nor O_TMPFILE is specified in flags, then mode is ignored
(and can thus be specified as 0, or simply omitted).  The
mode argument must be supplied if O_CREAT or O_TMPFILE is
specified in flags; if it is not supplied, some arbitrary
bytes from the stack will be applied as the file mode.
The effective mode is modified by the process's umask in
the usual way: in the absence of a default ACL, the mode
of the created file is (mode & ~umask).
Note that mode applies only to future accesses of the
newly created file; the open() call that creates a read-
only file may well return a read/write file descriptor.
The following symbolic constants are provided for mode:
          S_IRWXU  00700 user (file owner) has read, write, and
                   execute permission
          S_IRUSR  00400 user has read permission
          S_IWUSR  00200 user has write permission
          S_IXUSR  00100 user has execute permission
          S_IRWXG  00070 group has read, write, and execute
                   permission
          S_IRGRP  00040 group has read permission
          S_IWGRP  00020 group has write permission
          S_IXGRP  00010 group has execute permission
          S_IRWXO  00007 others have read, write, and execute
                   permission
          S_IROTH  00004 others have read permission
          S_IWOTH  00002 others have write permission
          S_IXOTH  00001 others have execute permission
          According to POSIX, the effect when other bits are set in
          mode is unspecified.  On Linux, the following bits are
          also honored in mode:
          S_ISUID  0004000 set-user-ID bit
          S_ISGID  0002000 set-group-ID bit (see inode(7)).
          S_ISVTX  0001000 sticky bit (see inode(7)).
          [...]
You have to make a call like:
auto file = ::open("file.dat", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
or something like that.