Hi,

I have to pass a void pointer in a function and at the other end I have to read some values from this void pointer.
I planned of creating a class and setting up required variables into an object and then I set this

void* ptr = obj

when I read it on the other end I am getting the following error:

"error: 'void*' is not a pointer-to-object type"

some one please help!

You might to include just a bit more of the code...I have no idea what a obj is. Is it a variable, a reference to a variable, a pointer....

Your error. Did you try casting the void pointer to the appropriate type.

Edited 6 Years Ago by gerard4143: n/a

Constructor of my class

CookieData :: CookieData(int s1, int d1, int t1, char* ipfile1)
{
	s = s1;
	d = d1;
	t = t1;
	ipfile = ipfile1;
}

passing this class object

CookieData* cookiedata = new CookieData(s,d,t,ipfile);
	void cookie = &cookiedata;
	setfunction(cookie);   //function where I want these values, cookie has to be a void pointer by function declaration
CookieData* cookiedata = new CookieData(s,d,t,ipfile);
	void cookie = &cookiedata;
	setfunction(cookie);   //function where I want these values, cookie has to be a void pointer by function declaration

I'm pretty sure you want something like this:

CookieData* cookiedata = new CookieData(s,d,t,ipfile);
	void *cookie = cookiedata;
	setfunction(cookie);

yeah..I figured it.. basically I type casted the void pointer with a object type pointer and then I could use it as a object!

Thanks for your help!

This question has already been answered. Start a new discussion instead.