Click here to Skip to main content
15,886,518 members
Articles / Programming Languages / C++

COM Concept : Unleashing Aggregation

Rate me:
Please Sign up or sign in to vote.
4.84/5 (30 votes)
30 Oct 20036 min read 87K   1.3K   56  
Unleashing Aggregation
#include<objbase.h>

#define interface struct
#define _STDCALL	 __stdcall

interface IAddSub : IUnknown {

	virtual void _STDCALL GetAdd(int Val1,int Val2,int* pResult) = 0;
	virtual void _STDCALL GetSub(int Val1,int Val2,int* pResult) = 0;
	
};


interface INonDelegateUnknown {
	
	virtual HRESULT _STDCALL NonDelegateQueryInterface (const IID&, void**) = 0;
	virtual ULONG _STDCALL NonDelegateAddRef() = 0;
	virtual ULONG _STDCALL NonDelegateRelease() = 0;
	
};

extern "C" {

	extern const IID IID_IAddSub;
	extern const IID IID_INonDelegateUnknown;
	
}


class CBasic : public IAddSub, public INonDelegateUnknown {

public:
	
	// Implementing Delegating IUnknown Interface. The Delegating
	// IUnknown interface is the interface which is inherited
	// by the IAddSub interface.
	virtual HRESULT _STDCALL QueryInterface(const IID& iid,void **ppv);
	virtual ULONG _STDCALL AddRef();
	virtual ULONG _STDCALL Release();

	// Implementing NonDelegating IUnknown Interface.
	virtual HRESULT _STDCALL NonDelegateQueryInterface (const IID&, void**);
	virtual ULONG _STDCALL NonDelegateAddRef();
	virtual ULONG _STDCALL NonDelegateRelease();
	

	//Implementing IAddSub Interface.
	virtual void _STDCALL GetAdd(int Val1,int Val2,int* pResult);
	virtual void _STDCALL GetSub(int Val1,int Val2,int* pResult);
	
	// Constructor 
	CBasic(IUnknown* m_pOuterUnknown);

	// Destructor
	~CBasic();
	
	long m_cInnerRef;
	
	IUnknown* m_pOuterUnknown;

};

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions