Guest User

Untitled

a guest
Jan 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class Set
  6. {
  7. private:
  8. char *num;size_t size;
  9. public:
  10. int min();
  11. void sort();
  12. void unique();
  13. bool find();
  14. Set(){}
  15. Set(char *str)
  16. {
  17. size = strlen(str);
  18. num = new char[size];
  19. for(int i=0; i<size; i++)
  20. {
  21. num[i] = str[i];
  22. }
  23. //sort();
  24. //unique();
  25. }
  26. const Set& push(char *str)
  27. {
  28. char *temp = new char[size+strlen(str)];
  29. for(int i=0; i<size; i++)
  30. {
  31. temp[i] = num[i];
  32. }
  33. temp[size] = *str;
  34. delete [] num;
  35. this->num = temp;
  36. this->size += strlen(str);
  37. return *this;
  38. }
  39.  
  40. const Set operator+(const Set& s)
  41. {
  42. if(this->size != s.size)
  43. {
  44. return NULL;
  45. }
  46. Set v;
  47. size = v.size + size;
  48. for(int i=0; i<size; i++)
  49. {
  50. v.num[i] = num[i] + s.num[i];
  51. }
  52. return v;
  53. }
  54. friend const ostream& operator<<(ostream& os, const Set& s);
  55. };
  56.  
  57. const ostream& operator<<(ostream& os, const Set& s)
  58. {
  59. for(int i=0; i<s.size; i++)
  60. {
  61. os << s.num[i];
  62. }
  63. return os;
  64. }
  65.  
  66. int main(int argc, const char * argv[]) {
  67. // insert code here...
  68. std::cout << "Hello, World!n";
  69. char s[25] = "Hello world ";
  70. Set ss(s);
  71. char q[25] = "Holan";
  72. ss.push(q);
  73. Set sw(q);
  74. ss = ss + sw;
  75. cout << ss;
  76. return 0;
  77. }
Add Comment
Please, Sign In to add comment