12345678910111213141516171819202122232425 |
- #include <iostream>
- #include "originator.hh"
- #include "caretaker.hh"
- int main(){
- Originator* originator = new Originator;
- CareTaker* careTaker = new CareTaker;
- originator->setState("State #1");
- careTaker->add(originator->saveStateToMemento());
- originator->setState("State #2");
- careTaker->add(originator->saveStateToMemento());
- originator->setState("State #3");
- std::cout << "Current State: " << originator->getState() << std::endl;
- originator->getStateFromMemento(careTaker->get(0));
- std::cout << "First save State: " << originator->getState() << std::endl;
- originator->getStateFromMemento(careTaker->get(1));
- std::cout << "Second saved State: " << originator->getState() << std::endl;
-
- }
|