Quote:Original post by jpetrie
And what were the errors you saw?
In your first attempt, you called "Grid()", but there is no function named Grid(), there is a function called Primitive::Grid() -- a member of the Primitive class. Since it's not a static member, you need an instance of Primitive to call it:
Primitive primitive;primitive.Grid();
I attempted just about every combination of everything before i posted... ;)
The "//Grid();" I commented out just to show, i was previously just calling it from the same class (inline), but now i want to call it from "Primitive".
Quote:Your attempt created a pointer to a Primitive (Primitive*) which you never allocated storage for and just tried to use immediately, which likely will cause a crash.
Declaring the instance as a non-pointer should work, in terms of compilation, but it may not be semantically correct at runtime (i.e., it may not do what you want) because that depends very much on code that you are not showing us -- what Primitive looks like and does, what the rest of the iD3D10 class does, et cetera).
I'm happy to post my code, it's i just thought the longer the message, the less chance for reply... And i really want to get the Class thing down.
Okay so if i do as you suggest i get the following errors.
1>.\iD3D10.cpp(101) : error C2065: 'Primitive' : undeclared identifier1>.\iD3D10.cpp(101) : error C2146: syntax error : missing ';' before identifier 'Prim'1>.\iD3D10.cpp(101) : error C2065: 'Prim' : undeclared identifier1>.\iD3D10.cpp(102) : error C2065: 'Prim' : undeclared identifier1>.\iD3D10.cpp(102) : error C2228: left of '.Cube' must have class/struct/union
Now, I assume the above is because i now need to have my iD3D10 header file have "#include "primitive.h"
So this causes some design issues:
//Primitive.cpp#include "Primitive.h"#include "iD3D10.h"//iD3D10.cpp#include <QWidget>#include <QtGui>#include <d3d10.h>#include <d3dx10.h>#include "Primitive.h"#include "iD3D10.h"
So i have to include the same files twice, which seems like it's always going to cause grief. Now i have Linker errors:
1>main.obj : error LNK2005: "struct ID3D10Device * g_pd3dDevice" (?g_pd3dDevice@@3PEAUID3D10Device@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct IDXGISwapChain * g_pSwapChain" (?g_pSwapChain@@3PEAUIDXGISwapChain@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10RenderTargetView * g_pRenderTargetView" (?g_pRenderTargetView@@3PEAUID3D10RenderTargetView@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10Effect * g_pEffect" (?g_pEffect@@3PEAUID3D10Effect@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10EffectTechnique * g_pTechnique" (?g_pTechnique@@3PEAUID3D10EffectTechnique@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10InputLayout * g_pVertexLayout" (?g_pVertexLayout@@3PEAUID3D10InputLayout@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10Buffer * g_pVertexBuffer" (?g_pVertexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10Buffer * g_pIndexBuffer" (?g_pIndexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10RasterizerState * g_pRasterizerState" (?g_pRasterizerState@@3PEAUID3D10RasterizerState@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pWorldVariable" (?g_pWorldVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pViewVariable" (?g_pViewVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pProjectionVariable" (?g_pProjectionVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct D3DXMATRIX g_View" (?g_View@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct D3DXMATRIX g_World" (?g_World@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>main.obj : error LNK2005: "struct D3DXMATRIX g_Projection" (?g_Projection@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10Device * g_pd3dDevice" (?g_pd3dDevice@@3PEAUID3D10Device@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct IDXGISwapChain * g_pSwapChain" (?g_pSwapChain@@3PEAUIDXGISwapChain@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10RenderTargetView * g_pRenderTargetView" (?g_pRenderTargetView@@3PEAUID3D10RenderTargetView@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10Effect * g_pEffect" (?g_pEffect@@3PEAUID3D10Effect@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10EffectTechnique * g_pTechnique" (?g_pTechnique@@3PEAUID3D10EffectTechnique@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10InputLayout * g_pVertexLayout" (?g_pVertexLayout@@3PEAUID3D10InputLayout@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10Buffer * g_pVertexBuffer" (?g_pVertexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10Buffer * g_pIndexBuffer" (?g_pIndexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10RasterizerState * g_pRasterizerState" (?g_pRasterizerState@@3PEAUID3D10RasterizerState@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pWorldVariable" (?g_pWorldVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pViewVariable" (?g_pViewVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pProjectionVariable" (?g_pProjectionVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct D3DXMATRIX g_View" (?g_View@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct D3DXMATRIX g_World" (?g_World@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>Primitive.obj : error LNK2005: "struct D3DXMATRIX g_Projection" (?g_Projection@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10Device * g_pd3dDevice" (?g_pd3dDevice@@3PEAUID3D10Device@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct IDXGISwapChain * g_pSwapChain" (?g_pSwapChain@@3PEAUIDXGISwapChain@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10RenderTargetView * g_pRenderTargetView" (?g_pRenderTargetView@@3PEAUID3D10RenderTargetView@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10Effect * g_pEffect" (?g_pEffect@@3PEAUID3D10Effect@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10EffectTechnique * g_pTechnique" (?g_pTechnique@@3PEAUID3D10EffectTechnique@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10InputLayout * g_pVertexLayout" (?g_pVertexLayout@@3PEAUID3D10InputLayout@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10Buffer * g_pVertexBuffer" (?g_pVertexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10Buffer * g_pIndexBuffer" (?g_pIndexBuffer@@3PEAUID3D10Buffer@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10RasterizerState * g_pRasterizerState" (?g_pRasterizerState@@3PEAUID3D10RasterizerState@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pWorldVariable" (?g_pWorldVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pViewVariable" (?g_pViewVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct ID3D10EffectMatrixVariable * g_pProjectionVariable" (?g_pProjectionVariable@@3PEAUID3D10EffectMatrixVariable@@EA) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct D3DXMATRIX g_View" (?g_View@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct D3DXMATRIX g_World" (?g_World@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>moc_iD3D10.obj : error LNK2005: "struct D3DXMATRIX g_Projection" (?g_Projection@@3UD3DXMATRIX@@A) already defined in iD3D10.obj1>D:\Development\Projects\MainWin\Debug\MainWin.exe : fatal error LNK1169: one or more multiply defined symbols found
And now I have 46 Linker errors, and OOP and C++ is scaring me, when all i want to do is make my code a little neater: :)All advice is welcomed.
[Edited by - Zahlman on October 28, 2009 11:02:31 PM]