Advertisement
thevals

asdble

Mar 18th, 2022
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. stroka::stroka(const char* S) :len(), pCh()
  2. {
  3.     //strcpy_s(pCh, len + 1, S);
  4.     len = 0;
  5.     const char *cptr = S;
  6.     while (*(cptr++) != '\0') len++;
  7.     pCh = new char[len + 1];
  8.     char *ptr1 = pCh;
  9.     const char *ptr2 = S;
  10.     for (int i = 0; i <= len; i++) {
  11.         *ptr1 = *ptr2;
  12.         ptr1++;
  13.         ptr2++;
  14.     }
  15.     cout << "stroka::stroka(const char* S)" << endl;
  16. }
  17. stroka::stroka(const stroka& from) :len(), pCh()
  18. {
  19.     len = 0;
  20.     const char* cptr = from.pCh;
  21.     while (*(cptr++) != '\0') len++;
  22.     pCh = new char[len + 1];
  23.     char* ptr1 = pCh;
  24.     const char* ptr2 = from.pCh;
  25.     for (int i = 0; i <= len; i++) {
  26.         *ptr1 = *ptr2;
  27.         ptr1++;
  28.         ptr2++;
  29.     }
  30.     cout << "stroka::stroka(const stroka& from)" << endl;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement