Advertisement
Cichacz

String

Jan 5th, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. String::String(const char znaki[])
  2. {
  3. n=strlen(znaki);
  4. this->znaki= new char[n+1];
  5. strcpy(this->znaki, znaki);
  6. printf("Dziala konstruktor dla slowa: %s\n", this->znaki);
  7. }
  8.  
  9. String::String(const String &s)
  10. {
  11. this->n=s.n;
  12. this->znaki= new char[n+1];
  13. strcpy(this->znaki, s.znaki);
  14. printf("Dziala konstruktor kopiujacy dla slowa: %s\n", this->znaki);
  15. }
  16.  
  17. void String::append(const char ch[])
  18. {
  19. n+=strlen(ch);
  20. char *z= new char[n+1];
  21. strcpy(z, this->znaki);
  22. strcat(z, ch);
  23. delete[] this->znaki;
  24. this->znaki = z;
  25. printf("Polaczony napis: %s\n", this->znaki);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement