Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with this code?

Status
Not open for further replies.

johnstv4

Programmer
Aug 20, 2002
7
0
0
GB
Hi everyone,

I'm trying to compile this code but VC++ gives an error saying:


e:\download\dcom-implement\branch.h(42) : error C2065: 'CBranchAccountList' : undeclared identifier


Here is branch.h:


// Branch.h : Declaration of the CBranch

#ifndef __BRANCH_H_
#define __BRANCH_H_

#include "resource.h" // main symbols

/////////////////////////////////////////////////////////////////////////////
// CBranch
class ATL_NO_VTABLE CBranch :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CBranch, &CLSID_Branch>,
public ISupportErrorInfo,
public IDispatchImpl<IBranch, &IID_IBranch, &LIBID_SERVERLib>
{
public:
CBranch()
{
m_pBranchAccountList = NULL;
}

~CBranch()
{
if (m_pBranchAccountList != NULL)
{
m_pBranchAccountList->Release();
}
}


DECLARE_REGISTRY_RESOURCEID(IDR_BRANCH)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CBranch)
COM_INTERFACE_ENTRY(IBranch)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

protected:
CComObject<CBranchAccountList> *m_pBranchAccountList;

// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IBranch
public:
STDMETHOD(get_BranchAccountList)(/*[out, retval]*/ LPDISPATCH *pVal);
};

#endif //__BRANCH_H_


And here is branch.cpp:


// Branch.cpp : Implementation of CBranch
#include &quot;stdafx.h&quot;
#include &quot;Server.h&quot;
#include &quot;BranchAccountList.h&quot;
#include &quot;Branch.h&quot;

/////////////////////////////////////////////////////////////////////////////
// CBranch

STDMETHODIMP CBranch::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IBranch
};
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (InlineIsEqualGUID(*arr,riid))
return S_OK;
}
return S_FALSE;
}

STDMETHODIMP CBranch::get_BranchAccountList(LPDISPATCH *pVal)
{
/*-----------------------------------------------------------*/
/* The BranchAccountList collection is built by &quot;procrastination.&quot; */
/* That is, it is not built until first asked for. Once */
/* built, it stays built for the life of the Top Level */
/* Object. That is, further references to the BranchAccountList */
/* property of the Top Level Object return the already */
/* created instance. */
/*-----------------------------------------------------------*/

LPDISPATCH pDisp = NULL;
HRESULT hr;

*pVal = NULL;

if (m_pBranchAccountList == NULL)
{

/*----------------------------------------------------*/
/* Create the BranchAccountList collection object, then */
/* invoke its InitCollection function (a user-defined */
/* function that initializes the collection). */
/*----------------------------------------------------*/

hr = CComObject<CBranchAccountList>::CreateInstance(&m_pBranchAccountList);

if (SUCCEEDED(hr))
{
m_pBranchAccountList->AddRef();
hr = m_pBranchAccountList->InitBranchAccountListCollection();
if (FAILED(hr))
{
delete m_pBranchAccountList;
m_pBranchAccountList = NULL;
return hr;
}
}
}

/*-----------------------------------------------*/
/* Return IDispatch pointer to BranchAccountList object */
/*-----------------------------------------------*/

hr = m_pBranchAccountList->QueryInterface (IID_IDispatch,(void **) pVal);

return hr;
}


Please any help is appreciated. Thanks.


John











 
#include &quot;BranchAccountList.h&quot;
I'm Assuming that is where you have CBranchAccountList defined?
is Branch.h only included in the Branch.cpp file?

What I would do is wrapper
#include &quot;BranchAccountList.h&quot;
between #ifndef __BRANCHACCOUNTLIST_H_
in the Branch.h file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top