Skip to main content
gamedev.net
🔒 Locked

typecasting a pointer to void to struct

Started by Dwiel 4 replies 200+ views
Original Post
Dwiel
Dwiel
hey, I have a pointer to void that contains data in the format of a structure "wall" defined in another class, which has been properly included. how do I avoid the error: cannot convert parameter 1 from ''void *'' to ''struct CWalls::wall *'' how do I do the convetion? thanx for the help dwiel ~ tazzel3d
IndirectX
IndirectX
Post some code.
---visit #directxdev on afternet <- not just for directx, despite the name
Dwiel
Dwiel

  

class CWalls
{
public:

struct wall
{
char name[64];
float x1;
float y1;
float z1;
float x2;
float y2;
float z2;
}wall;

struct LLwall
{
wall node;
LLwall *nextll;
}FirstNode;

AddWall(wall*);
LLwall *LastWall();

CWalls();
virtual ~CWalls();
};

class CCommandParse
{
public:

// some functions....


CWalls *walls;

CCommandParse();
virtual ~CCommandParse();

};

bool CCommandParse::ExecuteCommand()
{
//....

walls->AddWall(walls->*wall(com.data));
return true;
};


proplem is in the walls->AddWall(walls->*wall(com.data)); line... cant get the function to accept my void pointer

thanx for the quick response!

dwiel ~ tazzel3d
Crispy
Crispy
Are you looking for:


  

void function(void* object)
{
CWalls* walls = (CWalls*)object;
}


Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Oluseyi
Oluseyi
quote:
Original post by Crispy
Are you looking for <actual typecast omitted>?

No. He''s looking for (CWalls::wall *) object; since wall is a nested class.

Or, better yet, reinterpret_cast< CWalls::walls >( object ).
Dwiel
Dwiel
Oluseyi,
thanx for the help! "(CWalls::wall *) object;" worked perfectly!

dwiel ~ tazzel3d

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.