Guest User

Untitled

a guest
May 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class binFa
  5. {
  6. char value;
  7. binFa *righElem;
  8. binFa *leftElem;
  9.  
  10. public:
  11. binFa(char elem) : value(elem)
  12. {
  13. rightElem = NULL;
  14. leftElem = NULL;
  15. }
  16. binFa(const binFa &fa)
  17. {
  18. value = fa.value;
  19. rightElem = new binFa(fa.rightElem->value);
  20. leftElem = new binFa(fa.leftElem->value);
  21. }
  22. binFa &operator<<(char elem)
  23. {
  24. if (elem == '0')
  25. leftElem = new binFa(elem);
  26. else
  27. rightElem = new binFa(elem);
  28. return *this;
  29. }
  30. void writeStuff(binFa *fa)
  31. {
  32. std::cout << fa->value << " ";
  33. if (fa->rightElem != NULL || fa->leftElem != NULL)
  34. {
  35. kiir(fa->leftElem);
  36. kiir(fa->rightElem);
  37. }
  38. }
  39. std::ostream &operator<<(std::ostream &os)
  40. {
  41. os << this->value;
  42. return os;
  43. }
  44. };
  45.  
  46. int main()
  47. {
  48. binFa *obj = new binFa('/');
  49. *obj << '0' << '1' << '0';
  50. std::cout << obj;
  51. obj->writeStuff(obj);
  52. delete obj;
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment