By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

Observer pattern

P: n/a
mem
Class subject
{
private:
List<Observer*> *_observers;
....
};

Why use a pointer, _observers, above?

Is it really necessary to have Subject and Observer base classes in the
pattern? Instead, just pass a pointer of a class into another, and the
latter just informs the former by calling its member function, whenever
needed?

How to assign _observers to a List object?

Thanks!
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"mem" <me**@supnet.com> wrote in message
news:48*******************@bgtnsc04-news.ops.worldnet.att.net...
Class subject
{
private:
List<Observer*> *_observers;
...
};

Why use a pointer, _observers, above?
Why indeed? I can't think of a good reason.

Is it really necessary to have Subject and Observer base classes in the
pattern? Instead, just pass a pointer of a class into another, and the
latter just informs the former by calling its member function, whenever
needed?
How would you deal with pointers to different classes? How you you write a
list that can take an arbitary pointer and call use that pointer to call
specific member functions.

How to assign _observers to a List object?


That question makes no sense to me. Do you mean 'how to add an observer to
the _observers list?'. The answer to that would be use the appropriate
method of the List class.

john
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.