bool compare(const int &i1, const int &i2)
{
return i1 == i2;
}
int main()
{
bool (*pf)(const int &, const int &);
pf = &compare;
pf = compare;
cout << compare(1, 2) << endl;
cout << (*pf)(1, 1) << endl;
cout << pf(1,2) << endl;
return 0;
}
typedef bool (*cmpFcn)(const int &, const int &);
bool compare(const int &i1, const int &i2)
{
return i1 == i2;
}
int main()
{
cmpFcn pf;
cmpFcn pf2 = 0;
pf = compare;
pf2 = compare;
cout << pf(1, 1) << endl;
cout << pf2(1, 2) << endl;
return 0;
}
typedef bool (*cmpFcn)(const int &, const int &);
int add(const int &i1, const int &i2)
{
return i1 + i2;
}
bool compare(const char &c1, const char &c2)
{
return c1 == c2;
}
int main()
{
cmpFcn pf;
cmpFcn pf2;
pf = add;
pf = compare;
return 0;
}
typedef bool (*cmpFcn)(const int &, const int &);
bool compare(const int &i1, const int &i2)
{
return i1 == i2;
}
void useCompare(const int &i1, const int &i2,
bool (*pf)(const int &, const int &)
)
{
cout << pf(i1, i2) << endl;
}
int main()
{
cmpFcn pf = compare;
useCompare(1, 1, pf);
useCompare(1, 2, compare);
return 0;
}
int demo(int a) {return 666;}
int (*ff(int x))(int)
{
cout << x << endl;
return demo;
}
int main()
{
int a = 1;
cout << ff(2)(a) << endl;
return 0;
}
void ff(vector<double> vec)
{
cout << "void ff(vector<double> vec)" << endl;
}
void ff(unsigned int x)
{
cout << "void ff(unsigned int x)" << endl;
}
int main()
{
void (*pf)(int) = &ff;
void (*pf2)(unsigned) = &ff;
double (*pf3)(vector<double>) = &ff;
void (*pf4)(vector<double>) = &ff;
return 0;
}