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

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

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004