Class Function Pointer(solved)

Started by
3 comments, last by AKClaus 15 years, 9 months ago
Hi, Im learning Cplusplus and D3D, and wanted to pass a D3DXHANDLE* to my class so i can set the lights from there, but when i compile it says this: 1>Hd3d.obj : error LNK2019: unresolved external symbol "public: void __thiscall Light_class::SetDiffuseLights(char const * *,char const * *)" (?SetDiffuseLights@Light_class@@QAEXPAPBD00@Z) referenced in function "void __cdecl DrawScene(struct HWND__ *)" (?DrawScene@@YAXPAUHWND__@@@Z) and dont know what it is, can you help me ?. Here is my class and call to the function: (removed non important(working) stuff)

//CLASS:

class Light_class
{
public:
    Light_class( int max_ambiental, int max_diffuse );
    void SetDiffuseLights( D3DXHANDLE* position, D3DXHANDLE* power );
};

//the SetDiffuseLights function has nothing inside so the problem cant be there.

//CALL TO FUNCTION:

//declarations:

Light_class *lightobject;
D3DXHANDLE *hfx_DiffuseLight_position,
*hfx_DiffuseLight_power;

lightobject = new Light_class( 50, 50 );

//then i set the handles:

hfx_DiffuseLight_position = new D3DXHANDLE[ 2 ];
hfx_DiffuseLight_position[0] = effect->GetParameterByName( 0, "diffuse_lights[0].position" );
hfx_DiffuseLight_position[1] = effect->GetParameterByName( 0, "diffuse_lights[1].position" );
//{ ..same with but with power instead of position.. }

//then i call the function in the draw step:

lightobject->SetDiffuseLights( hfx_DiffuseLight_position, hfx_DiffuseLight_power );


Thanks for reading.
Advertisement
Looks like you're calling SetDiffuseLights without defining it.
>.< 12.41am not good for me. That solved it. Thanks a lot.
This appears to be a good lesson on why should omit details sparingly when you don't fully understand the problem. In this case, the linker is complaing that a function called SetDiffuseLights that is a member of Light_class, returns nothing, and takes two 'char const**' objects (what the D3DXHANDLE* type resolves to) could not be found.

That means you either have failed to define it, or defined it in such a way that it is not accessible, not viewed as the same function the linker expects, or was not actually compiled.

Where do you define this function and what does it look like?

[EDIT: Too slow, it seems]
The thing was that i havent defined it in the Lights.cpp after i added:
void Light_class::SetDiffuseLights(D3DXHANDLE *position, D3DXHANDLE *power){}


The problem was gone.
Thx for the explanation i understood better what was happening.

This topic is closed to new replies.

Advertisement