#### Archived

This topic is now archived and is closed to further replies.

# cannot instantiate abstract class

This topic is 5422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m not quite sure what I''m doing, but I can''t make an instance of the IDirect3D8 class ...
error C2259: ''IDirect3D8'' : cannot instantiate abstract class
due to following members:
''HRESULT IDirect3D8::QueryInterface(const IID &,void ** )'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(168) : see declaration of ''IDirect3D8::QueryInterface''
''ULONG IDirect3D8::AddRef(void)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(169) : see declaration of ''IDirect3D8::AddRef''
''ULONG IDirect3D8::Release(void)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(170) : see declaration of ''IDirect3D8::Release''
''HRESULT IDirect3D8::RegisterSoftwareDevice(void *)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(173) : see declaration of ''IDirect3D8::RegisterSoftwareDevice''
''UINT IDirect3D8::GetAdapterCount(void)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(174) : see declaration of ''IDirect3D8::GetAdapterCount''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(175) : see declaration of ''IDirect3D8::GetAdapterIdentifier''
''UINT IDirect3D8::GetAdapterModeCount(UINT)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(176) : see declaration of ''IDirect3D8::GetAdapterModeCount''
''HRESULT IDirect3D8::EnumAdapterModes(UINT,UINT,D3DDISPLAYMODE *)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(177) : see declaration of ''IDirect3D8::EnumAdapterModes''
''HRESULT IDirect3D8::GetAdapterDisplayMode(UINT,D3DDISPLAYMODE *)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(178) : see declaration of ''IDirect3D8::GetAdapterDisplayMode''
''HRESULT IDirect3D8::CheckDeviceType(UINT,D3DDEVTYPE,D3DFORMAT,D3DFORMAT,BOOL)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(179) : see declaration of ''IDirect3D8::CheckDeviceType''
''HRESULT IDirect3D8::CheckDeviceFormat(UINT,D3DDEVTYPE,D3DFORMAT,DWORD,D3DRESOURCETYPE,D3DFORMAT)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(180) : see declaration of ''IDirect3D8::CheckDeviceFormat''
''HRESULT IDirect3D8::CheckDeviceMultiSampleType(UINT,D3DDEVTYPE,D3DFORMAT,BOOL,D3DMULTISAMPLE_TYPE)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(181) : see declaration of ''IDirect3D8::CheckDeviceMultiSampleType''
''HRESULT IDirect3D8::CheckDepthStencilMatch(UINT,D3DDEVTYPE,D3DFORMAT,D3DFORMAT,D3DFORMAT)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(182) : see declaration of ''IDirect3D8::CheckDepthStencilMatch''
''HRESULT IDirect3D8::GetDeviceCaps(UINT,D3DDEVTYPE,D3DCAPS8 *)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(183) : see declaration of ''IDirect3D8::GetDeviceCaps''
''HMONITOR IDirect3D8::GetAdapterMonitor(UINT)'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(184) : see declaration of ''IDirect3D8::GetAdapterMonitor''
''HRESULT IDirect3D8::CreateDevice(UINT,D3DDEVTYPE,HWND,DWORD,D3DPRESENT_PARAMETERS *,IDirect3DDevice8 ** )'' : pure virtual function was not defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\d3d8.h(185) : see declaration of ''IDirect3D8::CreateDevice''

##### Share on other sites
You can''t declare instances of the D3D interfaces. Call Direct3DCreate8() to get a pointer to one.

That should have been the first thing you learned in D3D. Tell me you''re not trying to do this without at least reading the preliminary docs first.

I like pie.

##### Share on other sites
here''s the example they gave.
IDirect3D8 g_D3D;if((g_D3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL){//error}

##### Share on other sites
I know s***t about DX, but in general abstract classes (aka interfaces, so that's the 'I' in front of IDirect3D8) are not to be instantiated. Try deriving from it and defining the pure virtual functions in your derived class if you are sure you should use this class.
But I guess there is another way.

edit: nevermind, I'm slow at typing.
edit2: googling gave: http://www.andypike.com/Tutorials/DirectX8/001.asp
hope it helps.

[edited by - SwSh on January 12, 2004 5:13:58 AM]

[edited by - SwSh on January 12, 2004 5:17:03 AM]

##### Share on other sites
I think it should be a pointer to the interface, i.e.
IDirect3D8 *g_D3D;if((g_D3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL){  //error}

Or you can use LPDIRECT3D8 instead of IDirect3D8*.

Hope this helps,

PhilHalf

##### Share on other sites
quote:
Original post by PhilHalf
I think it should be a pointer to the interface, i.e.
IDirect3D8 *g_D3D;if((g_D3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL){  //error}

Or you can use LPDIRECT3D8 instead of IDirect3D8*.

Hope this helps,

PhilHalf

I get this

WinMain.obj : error LNK2019: unresolved external symbol _Direct3DCreate8@4 referenced in function _WinMain@16
Debug/Win32APP.exe : fatal error LNK1120: 1 unresolved externals

##### Share on other sites
You need to link in the libraries as well as include the header files.
The header file that you need is d3d8.h and the libraries are d3d8.lib and dxguid.lib. Just right click on the solution name on the Solution Explorer, select Properties, go into Linker and in the Command Line Options (I think) you need to type in the two libraries that I''ve mentioned.

Hope this helps,

PhilHalf

##### Share on other sites
quote:
Original post by PhilHalf
You need to link in the libraries as well as include the header files.
The header file that you need is d3d8.h and the libraries are d3d8.lib and dxguid.lib. Just right click on the solution name on the Solution Explorer, select Properties, go into Linker and in the Command Line Options (I think) you need to type in the two libraries that I''ve mentioned.

Hope this helps,

PhilHalf
Yeah it does, but why exactly don''t they mention anything about dxguid.lib in the book? *Programming RolePlaying Games in DX*

##### Share on other sites
I''m not sure you actually need dxguid.lib for the example that you gave, but it''s likely that you will use it later for other things. I know for example that you need it to use GUID_SysKeyboard with DirectInput among other things.
You could have just linked d3d8.lib. I seem to remember that Programming RPGs says that you need to link this in a small note box somewhere or something.

PhilHalf

##### Share on other sites
Because they probably expect you to have some basic programming knowledge, or use the supplied samples (if there is any).

1. 1
Rutin
34
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633333
• Total Posts
3011404
• ### Who's Online (See full list)

There are no registered users currently online

×