Int the current implementation of observer pattern, observer can only get abstract Subject*. In this case, the observer cannot tell what subject it is.
So, I wonder if there is any way to support typing in this pattern? If template is used, can it avoid another embarrassing matter that the implementation must be placed in the header file?
For example, I want to do things like this:
class ConcreteObserver : public Observer
{
public:
void Update(ConcreteSubject& subject);
}
Int the current implementation of observer pattern, observer can only get abstract
Subject*. In this case, the observer cannot tell what subject it is.So, I wonder if there is any way to support typing in this pattern? If template is used, can it avoid another embarrassing matter that the implementation must be placed in the header file?
For example, I want to do things like this: