I have this class and I am trying to extract x1 function from pointer of my class pointer
class myclass
{
public:
myclass();
~myclass();
int x = 0;
int x1();
private:
};
int myclass::x1()
{
return 100;
}
like this
myclass* ptr = new myclass[10];
for (int i = 0; i < 10; i++)
ptr[i].x = i*11;
for (int i = 0; i < 10; i++)
{
std::cout << ((ptr + i)->x) << std::endl;
void *v = (void *)((ptr + i)->x);
typedef int (*fptr)()=//what I need to do to v to get x1 function and call it;
}
can I do this. Is this allowed in C++. I am using VS2019