Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. iString::iString(const char * chars)
  2. {
  3. if(chars)
  4. {
  5. length = strlen(chars);
  6. capacity = length + 10 + 1;
  7. this->chars = new char[capacity];
  8. strcpy(this->chars, chars);
  9. }
  10. else
  11. {
  12. length =0;
  13. this->chars = NULL;
  14. capacity = 0;
  15.  
  16. }
  17. }
  18.  
  19. iString::iString(const iString & other) : length(other.length), capacity(other.capacity)
  20. {
  21. if(capacity != 0)
  22. {
  23. chars = new char[capacity];
  24. strcpy(chars, other.chars);
  25. }
  26. else
  27. {
  28. chars = NULL;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement