Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class Set
- {
- private:
- char *num;size_t size;
- public:
- int min();
- void sort();
- void unique();
- bool find();
- Set(){}
- Set(char *str)
- {
- size = strlen(str);
- num = new char[size];
- for(int i=0; i<size; i++)
- {
- num[i] = str[i];
- }
- //sort();
- //unique();
- }
- const Set& push(char *str)
- {
- char *temp = new char[size+strlen(str)];
- for(int i=0; i<size; i++)
- {
- temp[i] = num[i];
- }
- temp[size] = *str;
- delete [] num;
- this->num = temp;
- this->size += strlen(str);
- return *this;
- }
- const Set operator+(const Set& s)
- {
- if(this->size != s.size)
- {
- return NULL;
- }
- Set v;
- size = v.size + size;
- for(int i=0; i<size; i++)
- {
- v.num[i] = num[i] + s.num[i];
- }
- return v;
- }
- friend const ostream& operator<<(ostream& os, const Set& s);
- };
- const ostream& operator<<(ostream& os, const Set& s)
- {
- for(int i=0; i<s.size; i++)
- {
- os << s.num[i];
- }
- return os;
- }
- int main(int argc, const char * argv[]) {
- // insert code here...
- std::cout << "Hello, World!n";
- char s[25] = "Hello world ";
- Set ss(s);
- char q[25] = "Holan";
- ss.push(q);
- Set sw(q);
- ss = ss + sw;
- cout << ss;
- return 0;
- }
Add Comment
Please, Sign In to add comment