home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1991 / 10 / string / strictor.cpp < prev    next >
C/C++ Source or Header  |  1991-07-30  |  593b  |  36 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3. #include <errno.h>
  4. #include <string.hpp>
  5.  
  6. String::String() : rp(0) {}
  7.  
  8. String::String(const char *s, int count)
  9. {
  10.     int n = count? count: strlen(s);
  11.     if (n >= 0) {
  12.         rp = new(n) srep(n,s);
  13.         if (!rp)
  14.             errno = ENOMEM;
  15.         else 
  16.             rp->refs++;
  17.     } else
  18.         rp = 0;
  19. }
  20.  
  21. String::String(char c)
  22. {
  23.     rp = new(1) srep(1,&c);
  24.     if (!rp)
  25.         errno = ENOMEM;
  26.     else 
  27.         rp->refs++;
  28. }
  29.  
  30. String::String(const String &s)
  31. {
  32.     rp = s.rp;
  33.     if (rp)
  34.         rp->refs++;
  35. }
  36.