Click here to Skip to main content
15,881,898 members
Articles / Programming Languages / Objective C

Applying Observer Pattern in C++ Applications

Rate me:
Please Sign up or sign in to vote.
4.69/5 (27 votes)
8 Jan 2001 158.1K   2.1K   109  
This article explains how to avoid object dependencies using the Observer Pattern with a simple example.
// Observer.h : interface of the CObserver class
//
/////////////////////////////////////////////////////////////////////////////

#ifndef _OBSERVER
#define _OBSERVER

// Forward declare the class CSubject
class CSubject;

// Class declaration for CObserver
class CObserver
{
	// Destructor
	public :
		virtual ~CObserver();

	// Methods
	public :
		virtual BOOL Update( CSubject * ) = 0;

	// Protected constructor
	protected :
		CObserver();
};
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Switzerland Switzerland
Kulathu Sarma is working as a Technology Manager for GoldAvenue, a company based in Geneva, Switzerland and responsible for supporting e-business initiatives of GoldAvenue in B2B and B2C Sectors. He has been programming in C/C++ for 9 years and actively working on Patterns for the past 5 years.

Comments and Discussions