Public Group

# Class Function Pointer(solved)

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

## Recommended Posts

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-&gt;GetParameterByName( 0, "diffuse_lights[0].position" );
hfx_DiffuseLight_position[1] = effect-&gt;GetParameterByName( 0, "diffuse_lights[1].position" );
//{ ..same with but with power instead of position.. }

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

lightobject-&gt;SetDiffuseLights( hfx_DiffuseLight_position, hfx_DiffuseLight_power );



##### Share on other sites
Looks like you're calling SetDiffuseLights without defining it.

##### Share on other sites
>.< 12.41am not good for me. That solved it. Thanks a lot.

##### Share on other sites
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]

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5
khawk
11

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633671
• Total Posts
3013266
×