S
Steve
I am trying to get a handle on function pointers, trying this example
program in Visual Studio:
#include <iostream.h>
class TestingUp
{
public:
TestingUp()
{
}
TestFunc(void(*ptr)())
{
ptr();
}
};
class TestingDown
{
public:
TestingDown()
{
x = 8;
y = 25;
pfv = Display;
test.TestFunc(pfv);
}
void Display()
{
cout << "At this time the value of x is " << x << endl;
cout << "At this time the value of y is " << y << endl;
}
protected:
int x;
int y;
void (*pfv)();
TestingUp test;
};
int main()
{
TestingDown downTest;
return 0;
}
Getting the cryptic error:
error C2440: '=' : cannot convert from 'void (__thiscall
TestingDown::*)(void)' to 'void (__cdecl *)(void)'
How do I fix that? Websites on function pointer syntax and callback
use are cryptic at best. Thanks for any help that can be provided.
program in Visual Studio:
#include <iostream.h>
class TestingUp
{
public:
TestingUp()
{
}
TestFunc(void(*ptr)())
{
ptr();
}
};
class TestingDown
{
public:
TestingDown()
{
x = 8;
y = 25;
pfv = Display;
test.TestFunc(pfv);
}
void Display()
{
cout << "At this time the value of x is " << x << endl;
cout << "At this time the value of y is " << y << endl;
}
protected:
int x;
int y;
void (*pfv)();
TestingUp test;
};
int main()
{
TestingDown downTest;
return 0;
}
Getting the cryptic error:
error C2440: '=' : cannot convert from 'void (__thiscall
TestingDown::*)(void)' to 'void (__cdecl *)(void)'
How do I fix that? Websites on function pointer syntax and callback
use are cryptic at best. Thanks for any help that can be provided.