hi, in the code below :
#include <iostream>
using namespace std;
struct deneme
{
int a;
void (* myFunction)(int a);
};
void function1(int a)
{
cout << a << endl;
}
void function2(int a)
{
cout << a + a << endl;
}
int main()
{
deneme myDeneme[] = {{1,function1},{2,function2}};
myDeneme[0].myFunction(myDeneme[0].a);
myDeneme[1].myFunction(myDeneme[1].a);
return 0;
}
i get the output:
1
4
which is correct.
My question is : the instance of my struct already includes the integer member "a", instead of passing it to the function as a parameter, is there any way of grabing that information from the struct it self?
Thanks