QtDesignPatterns/mementopattern/originator.h

26 lines
404 B
C
Raw Permalink Normal View History

2024-02-06 17:21:37 +08:00
#include "memento.h"
class Originator
{
public:
void setState(string state)
{
this->state = state;
}
string getState()
{
return this->state;
}
Memento *saveStateToMemento()
{
return new Memento(this->state);
}
void getStateFromMemento(Memento *memento)
{
this->state = memento->getState();
}
private:
string state;
};