Guest User

Untitled

a guest
Dec 12th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // CC Kendimiz Yazalım
  2.  
  3. #include <iostream>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. class Name {
  9. int m_len;
  10. char *m_p;
  11. public:
  12. Name(const char *p)
  13. {
  14. m_len = strlen(p);
  15. m_p = (char *)malloc(m_len + 1);
  16. ////
  17. strcpy(m_p, p);
  18. }
  19.  
  20. Name(const Name &r)
  21. {
  22. m_len = r.m_len;
  23. m_p = (char *)malloc(m_len + 1);
  24. ///
  25. strcpy(m_p, r.m_p);
  26. }
  27.  
  28. ~Name()
  29. {
  30. free(m_p);
  31.  
  32. }
  33. void display()const
  34. {
  35. cout << "(" << m_p << ")" << endl;
  36. }
  37. ////
  38. };
  39.  
  40.  
  41.  
  42. int main()
  43. {
  44. Name x{"Kerem Vatandas"};
  45. x.display();
  46. if (1) {
  47. Name y {x};
  48. y.display();
  49. getchar();
  50. }
  51.  
  52. x.display();
  53.  
  54. return 0;
  55. }
Add Comment
Please, Sign In to add comment