fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Set
  5. {
  6. private:
  7. struct Node
  8. {
  9. int val;
  10. Node* link;
  11. };
  12.  
  13. Node *cons(int x, Node *p);
  14. Node *list;
  15.  
  16.  
  17. public:
  18. Set() {list = NULL;}
  19. bool isEmpty() const;
  20. int size() const;
  21. bool member (int x) const;
  22. bool insert (int x);
  23. bool remove (int x);
  24. void print() const;
  25. const Set operator+(const Set &otherSet)const;
  26. const Set operator*(const Set &otherSet)const;
  27. Node* getSet()const{return list;}
  28. void setList(Node *list);
  29. friend ostream& operator <<(ostream& outputStream, const Set &set);
  30. };
  31.  
  32. ostream& operator <<(ostream& outputStream, const Set &set)
  33. {
  34. Set::Node *p;
  35. p = set.list;
  36. outputStream << '{';
  37. while(p->link != NULL)
  38. {
  39. outputStream << p->val;
  40. p = p->link;
  41. }
  42. outputStream << '}';
  43. return outputStream;
  44. }
  45.  
  46. int main() {
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 2676KB
stdin
Standard input is empty
stdout
Standard output is empty