From: Jack on
Hello,
This is the standard code found in Direct3D.
[code]
DECLARE_INTERFACE(ID3DXAllocateHierarchy)
{
// ID3DXAllocateHierarchy

//------------------------------------------------------------------------
// CreateFrame:
// ------------
// Requests allocation of a frame object.
//
// Parameters:
// Name
// Name of the frame to be created
// ppNewFrame
// Returns the created frame object
//
//------------------------------------------------------------------------
STDMETHOD(CreateFrame)(THIS_ LPCSTR Name,
LPD3DXFRAME *ppNewFrame) PURE;

//------------------------------------------------------------------------
// CreateMeshContainer:
// --------------------
// Requests allocation of a mesh container object.
//
// Parameters:
// Name
// Name of the mesh
// pMesh
// Pointer to the mesh object if basic polygon data found
// pPMesh
// Pointer to the progressive mesh object if progressive mesh data found
// pPatchMesh
// Pointer to the patch mesh object if patch data found
// pMaterials
// Array of materials used in the mesh
// pEffectInstances
// Array of effect instances used in the mesh
// NumMaterials
// Num elements in the pMaterials array
// pAdjacency
// Adjacency array for the mesh
// pSkinInfo
// Pointer to the skininfo object if the mesh is skinned
// pBoneNames
// Array of names, one for each bone in the skinned mesh.
// The numberof bones can be found from the pSkinMesh object
// pBoneOffsetMatrices
// Array of matrices, one for each bone in the skinned mesh.
//
//------------------------------------------------------------------------
STDMETHOD(CreateMeshContainer)(THIS_
LPCSTR Name,
CONST D3DXMESHDATA *pMeshData,
CONST D3DXMATERIAL *pMaterials,
CONST D3DXEFFECTINSTANCE *pEffectInstances,
DWORD NumMaterials,
CONST DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE;

//------------------------------------------------------------------------
// DestroyFrame:
// -------------
// Requests de-allocation of a frame object.
//
// Parameters:
// pFrameToFree
// Pointer to the frame to be de-allocated
//
//------------------------------------------------------------------------
STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE;

//------------------------------------------------------------------------
// DestroyMeshContainer:
// ---------------------
// Requests de-allocation of a mesh container object.
//
// Parameters:
// pMeshContainerToFree
// Pointer to the mesh container object to be de-allocated
//
//------------------------------------------------------------------------
STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER
pMeshContainerToFree) PURE;
};

[/code]


My declaration is....
[code]
class CAllocateHierarchy: public ID3DXAllocateHierarchy
{
private:
virtual HRESULT __stdcall CreateFrame(LPCTSTR Name, LPD3DXFRAME
*ppNewFrame);
virtual HRESULT __stdcall CreateMeshContainer(LPCTSTR Name, LPD3DXMESHDATA
pMeshData,
LPD3DXMATERIAL pMaterials, LPD3DXEFFECTINSTANCE pEffectInstances, DWORD
NumMaterials,
DWORD *pAdjacency, LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer);
virtual HRESULT __stdcall DestroyFrame(LPD3DXFRAME pFrameToFree);
virtual HRESULT __stdcall DestroyMeshContainer(LPD3DXMESHCONTAINER
pMeshContainerBase);
};
[/code]

after that, I tried to create an object of class CAllocateHierarchy, the
compiler complains

Error 1 error C2259: 'CAllocateHierarchy' : cannot instantiate abstract
class c:\documents and
settings\garfield\project1\project_sim\project_sim\project_simview.cpp 78
Project_Sim

What's wrong?
Thanks
Jack


From: Igor Tandetnik on
Jack wrote:
> //------------------------------------------------------------------------
> STDMETHOD(CreateFrame)(THIS_ LPCSTR Name,
> LPD3DXFRAME *ppNewFrame) PURE;
>
> //------------------------------------------------------------------------
> virtual HRESULT __stdcall CreateFrame(LPCTSTR Name, LPD3DXFRAME
> *ppNewFrame);

Name parameter is of type LPCSTR in the interface, but LPCTSTR in your
implementation. My guess is, you are building a Unicode build, where
LPCTSTR != LPCSTR.

> Error 1 error C2259: 'CAllocateHierarchy' : cannot instantiate
> abstract class c:\documents and
> settings\garfield\project1\project_sim\project_sim\project_simview.cpp
> 78 Project_Sim

A little further down that error message, the compiler tells you which
methods are left unimplemented. Too bad you chose to omit that part.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Jack on
> A little further down that error message, the compiler tells you which
> methods are left unimplemented. Too bad you chose to omit that part.
>
Sorry Igor,
Here is the complete message
1>c:\documents and
settings\garfield\project1\project_sim\project_sim\project_simview.cpp(78) :
error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class
1> due to following members:
1> 'HRESULT ID3DXAllocateHierarchy::CreateFrame(LPCSTR,LPD3DXFRAME
*)' : is abstract
1> d:\program files\microsoft directx sdk (october
2006)\include\d3dx9anim.h(134) : see declaration of
'ID3DXAllocateHierarchy::CreateFrame'
1> 'HRESULT ID3DXAllocateHierarchy::CreateMeshContainer(LPCSTR,const
D3DXMESHDATA *,const D3DXMATERIAL *,const D3DXEFFECTINSTANCE *,DWORD,const
DWORD *,LPD3DXSKININFO,LPD3DXMESHCONTAINER *)' : is abstract
1> d:\program files\microsoft directx sdk (october
2006)\include\d3dx9anim.h(168) : see declaration of
'ID3DXAllocateHierarchy::CreateMeshContainer'

Actually I need unicode build due to dxut requirement.
Thanks
Jack


From: Alex Blekhman on
"Jack" <jl(a)knight.com> wrote:
> Here is the complete message
> [...]

So, the compiler tells you exactly what methods are abstract. Look
at your ID3DXAllocateHierarchy::CreateFrame and
ID3DXAllocateHierarchy::CreateMeshContainer declarations and fix
LPCTSTR parameter.

Alex