DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
No More Array Errors (Part I) - Block(C++)

The size operation

Another way to request reallocation explicitly is to use the size() operation. This version, which takes a single parameter (the new size), should not be confused with the parameterless version discussed in the section ``What is array reallocation?'', which simply returns the current size. The following example uses both operations:

       Block<int> b(100);
       ...
       b.size( 2*b.size() );  // size is now 200

The one-parameter size() operation returns the new size or zero in the event that reallocation failed.

Note that if the argument to size() is less than the current allocation, truncation will occur.


Next topic: Conclusion
Previous topic: The reserve operation

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005