Using Iostream Classes for Formatted Output
Example 5 shows how to use the iostream classes for formatted output into a portal.
Example 5 – Using iostream classes for formatted output into a portal
// set up the RWPortal object, portal
 
RWPortalOStream ostrm(portal); //1
ostrm << "hello world" << endl; //2
//1 Sets up an ostream object, which uses the RWPortal object portal for its sink of bytes. The RWPortalOStream makes its own copy of the portal, which enables you to specify a temporary object in the constructor.
//2 Outputs objects using the stream. Because the RWPortalOStream class is derived from ostream, any objects that can be inserted into an ostream can also be inserted into an RWPortalOStream.