Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cstring>
  4. #include "stdio.h"
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8. class tekst {
  9. char *p;
  10. public:
  11. tekst() {
  12. p = new char[1];
  13. }
  14. void assign(char *t) {
  15. strcpy(p, t);
  16. }
  17. tekst(char *t) {
  18. p = t;
  19. }
  20. void operator=(tekst a) {
  21. strcpy(p, a.p);
  22. }
  23. void print() {
  24. cout << p << endl; //użyć printf bo cout ssie
  25. }
  26. void operator!() {
  27. cout << this->p << endl; //tu to samo
  28. }
  29.  
  30. tekst operator+(tekst a) {
  31. strcat(p, a.p);
  32. return *this;
  33. }
  34.  
  35. };
  36.  
  37. int main()
  38. {
  39. tekst a, b, c;
  40. b.assign("Tekscior"); //tu może wywali błąd ale podobno jest ładnie więc co sie bede kłócił
  41. b.print();
  42. a = b;
  43. !a;
  44. _getch();
  45. a.assign("Tekst");
  46. c = a + b;
  47. !b;
  48. !a;
  49. !c;
  50. _getch();
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement