Skip to content

Type information in observer pattern? #1

@Lord-Turmoil

Description

@Lord-Turmoil

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions