Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- class binFa
- {
- char value;
- binFa *righElem;
- binFa *leftElem;
- public:
- binFa(char elem) : value(elem)
- {
- rightElem = NULL;
- leftElem = NULL;
- }
- binFa(const binFa &fa)
- {
- value = fa.value;
- rightElem = new binFa(fa.rightElem->value);
- leftElem = new binFa(fa.leftElem->value);
- }
- binFa &operator<<(char elem)
- {
- if (elem == '0')
- leftElem = new binFa(elem);
- else
- rightElem = new binFa(elem);
- return *this;
- }
- void writeStuff(binFa *fa)
- {
- std::cout << fa->value << " ";
- if (fa->rightElem != NULL || fa->leftElem != NULL)
- {
- kiir(fa->leftElem);
- kiir(fa->rightElem);
- }
- }
- std::ostream &operator<<(std::ostream &os)
- {
- os << this->value;
- return os;
- }
- };
- int main()
- {
- binFa *obj = new binFa('/');
- *obj << '0' << '1' << '0';
- std::cout << obj;
- obj->writeStuff(obj);
- delete obj;
- return 0;
- }
Add Comment
Please, Sign In to add comment