Classes that do not need to be streamable

Classes that do not need streaming operators have the following characteristics:

What you cannot stream

Streaming an integer is undefined. The reason for this is related to the size of int being undefined relative to a specific hardware platform. Consequently, you cannot stream a variable of type int.

If you try to stream an int, you will likely get "overload error" messages at compile time indicating that multiple functions match your code. To make the variable streamable, you must decide what valid streaming format you want to use, such as the data type long or short.

How to recognize non-streaming classes

Because some classes might not define streaming operators, you need to be able to recognize this so you don't try to stream any instances of that class. Here are some of the ways to determine if a class is not streamable:

    When you compile your program, the compiler gives you an error message stating it cannot find the stream operators in the class you are trying to access.
    The class might not have any operators defined at all. You can verify this by looking at the class definition.
    There are stream operators defined, but they are in the private section of the class definition. By being private, they are not available to other classes.

Portions of instances t hat are not streamed

When streaming an object, the data written to the stream builds the information needed to fully resurrect the object. The amount of information written is further influenced depending on what type of stream you are writing to. For more information on stream types, see
"Freeze levels" on page 86.

When writing the streaming member functions for your own class, you are the only person who knows what is important and what must be streamed. What is important varies from instance to instance, but you need to stream out the most relevant data and state information needed to recreate the instance when it is streamed in.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker