Click here to Skip to main content
14,880,500 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hallo Rahul Rajat Singh,
I have small question regarding Observer Pattern in C++.
Isn't it the

C++
class ASubject
{
    //Lets keep a track of all the shops we have observing
    std::vector<iobserver*> list;

public:
    void Attach(IObserver *product);
    void Detach(IObserver *product);
    void Notify(float price); 
};


and Shop should be publicly derived from IObserver ?

C++
class Shop : public IObserver
{
    //Name of the Shop
    std::string name;
    float price;
public:
    Shop(std::string n); 
    void Update(float price);   
    ~Shop() { std::cout << " In ~Shop()" << "\n";}
};
Posted
Updated 16-Apr-15 6:18am
v2

1 solution

If you have any question to Rahul Rajat Singh[^], please post it in message board to His article[^] (on bottom of page).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900