Objects of the ofstream class can be constructed and destructed.
public:~ofstream()
This is supported on

Destructs an ofstream object.
Constructs an object of this class.
public:ofstream(int fd, char* p, int l)
This is supported on

Constructs an ofstream object that is attached to the file descriptor fd. If fd is not open, ios::failbit is set in the format state of the ofstream object. This constructor also sets up an associated filebuf object with a stream buffer that has length l bytes and begins at the position pointed to by p. If p is equal to 0 or l is equal to 0, the associated filebuf object is unbuffered.
This function is available for 32-bit applications. The third argument is an int value.
public:ofstream( const char* name,
const char* attr,
int mode = ios::out,
int prot = filebuf::openprot )
This is supported on

Constructs an ofstream object and opens the file name with open mode equal to mode, attributes equal to attr and protection mode equal to prot. The default value for the argument prot is filebuf::openprot. If the file cannot be opened, the error state of the constructed fstream object is set.
You can use the attr parameter to specify additional file attributes such as lrecl or recfm. All the parameters documented for the fopen() functions are supported, with the exception of type=record.
The prot attribute is ignored.
public:ofstream(int fd)
This is supported on

Constructs an ofstream object that is attached to the file descriptor fd. If fd is not open, ios::failbit is set in the format state of the ofstream object.
public:ofstream(int fd, char* p, long l)
This is supported on

Constructs an ofstream object that is attached to the file descriptor fd. If fd is not open, ios::failbit is set in the format state of the ofstream object. This constructor also sets up an associated filebuf object with a stream buffer that has length l bytes and begins at the position pointed to by p. If p is equal to 0 or l is equal to 0, the associated filebuf object is unbuffered.
This function is available for 64-bit applications. The third argument is a long value.
public:ofstream( const char* name,
int mode = ios::out,
int prot = filebuf::openprot,
_CCSID_T ccsid = _CCSID_T ( 0 ) )
This is supported on

Constructs an ifstream object and opens the file name with open mode equal to mode and protection mode equal to prot, and ccsid equal to ccsid. The default value for the argument prot is filebuf::openprot. If the file cannot be opened, the error state of the constructed fstream object is set.
If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.
public:ofstream(const char* name, int mode, _CCSID_T)
This is supported on

Constructs an ofstream object and opens the file name with open mode equal to mode and ccsid equal to ccsid. If the file cannot be opened, the error state of the constructed fstream object is set.
If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.
public:ofstream( const char* name,
int mode = ios::out,
int prot = filebuf::openprot )
This is supported on

Constructs an ofstream object and opens the file name with open mode equal to mode and protection mode equal to prot. The default value for mode is ios::out and for prot is filebuf::openprot. If the file cannot be opened, the error state of the constructed ofstream object is set.
The prot attribute is ignored.
public:ofstream()
This is supported on

Constructs an unopened ofstream object.
public:filebuf* rdbuf()
This is supported on

Returns a pointer to the filebuf object that is attached to the ofstream object.
Opens the file.
The prot attribute is ignored.
Opens the specified file.
public:void
open( const char* name,
int mode = ios::out,
int prot = filebuf::openprot,
_CCSID_T ccsid = _CCSID_T ( 0 ) )
This is supported on

Opens the file with the specified name, mode, protection and coded character set id and attaches it to the fstream object.
If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.
The default value for prot is filebuf::openprot. If the fstream object is already attached to a file or if the call to fstream.rdbuf()->open() fails, ios::failbit is set in the error state for the fstream object.
The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.
If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.
public:void
open( const char* name,
int mode = ios::out,
int prot = filebuf::openprot )
This is supported on

Opens the file with the name and attaches it to the fstream object. If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.
The default value for prot is filebuf::openprot. If the fstream object is already attached to a file of if the call to fstream.rdbuf()->open() fails, ios::failbit is set in the error state for the fstream object.
The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.
public:void open(const char* name, int mode, _CCSID_T ccsid)
This is supported on

Opens the file with the specified name, mode and coded character set id and attaches it to the fstream object.
If the file with the name, name does not already exist, open() tries to create it unless ios::nocreate is set.
The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.
If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.
public:void
open( const char* name,
const char* attr,
int mode = ios::out,
int prot = filebuf::openprot )
This is supported on

Opens the file with the name and attaches it to the fstream object. If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.
You can use the attr parameter to specify additional file attributes, such as lrecl or recfm. All the parameters documented for the fopen() function are supported, with the exception of type=record.
The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.