I have a class MyClass in which there is one function that returns a pointer to QString:
QString* MyClass::generateName()
In other function I want to make a functions pointers’ array with generateName() in it. When I write
QString* (*array[1])() = {&MyClass::generateName};
I am getting an error:
cannot convert ‘QString* (MyClass::*)()’ to ‘QString* (*)()’ in initialization
When I remove MyClass:: from the array definition, it only gives me another error about the ISO. Besides, the former error remains.
What am I supposed to do to get rid of the error?
First with function pointers you should use typedefs:
Then, an array is easy to define: