I'm having a function that returns a a void data. And i need to receive it as a structure. eg. say a structure widget_data. a function GetObjectData() that returns a void data.
widget_data *wd=GetObjectData();
and GetObjectData() returns sd->data.
where sd is structure, data is of void type.
when i compile it i get error message like
invalid conversion from void* to widget_data*
static_cast can convert void* to a pointer to a specific type:
widget_data* wd = static_cast<widget_data*>( yourVoidPointer );
widget_data *wd=(widget_data *)GetObjectData();
or
widget_data *wd=reinterpret_cast<widget_data *>(GetObjectData());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With