I am trying to access the object's value returned in the void pointer, how can i access those values x and y through void pointer variable.
How can I access the value returned in that void pointer ???
#include <iostream.h>
void* getDetector();
class DETECTOR
{
public:
int x;
int y;
DETECTOR();
~DETECTOR();
};
void* getDetector()
{
return &DetectorObj;
}
DETECTOR::DETECTOR()
{
x = 10;
y = 20;
}
DETECTOR::~DETECTOR(){}
DETECTOR DetectorObj;
int main()
{
void * getPtr = getDetector();
cout<<getPtr->x;
return 0;
}