home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / data / mybuffer / mybuffer.cpp < prev   
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1006 b   |  43 lines

  1. //************************************************************
  2. // Data Types - Replacing the IString's IBuffer Object
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //
  8. //************************************************************
  9. #include <iostream.h>
  10. #include <istring.hpp>
  11. #include <ibuffer.hpp>
  12.  
  13. class MyBuffer : public IBuffer {
  14. public:
  15.   MyBuffer( unsigned len )
  16.     : IBuffer( len )
  17.     {
  18.     }
  19. virtual IBuffer
  20.  *allocate ( unsigned len ) const
  21.     {
  22.     return new (len) MyBuffer( len );
  23.     }
  24. virtual const char
  25.  *className ( ) const
  26.     {
  27.     return (const char*)"MyBuffer";
  28.     }
  29. };
  30.  
  31. void main()
  32.   {
  33.   IString
  34.     withDefault( "withDefault" );
  35.   cout << withDefault.asDebugInfo() << endl;
  36.   MyBuffer
  37.     root(0); // Allocate null buffer.
  38.   IBuffer::setDefaultBuffer( &root );
  39.   IString
  40.     withMyBuffer("withMyBuffer");
  41.   cout << withMyBuffer.asDebugInfo() << endl;
  42.   }
  43.