#include <stdio.h>
#include <iostream>
using namespace std;
typedef int (
*FT
) (const void* ,const void*);
//style of C++
int x=0;
extern "C"
{
typedef int (*CFT) (const void*,const void*)
;//style of C
void qsort(void* p,size_t n,size_t sz,CFT cmp)
//style of C
{
x=1;
cout<<"Hello"<<endl;
int result=cmp(0,0);
printf("in qsort,result is %d\n",result);
}
int y=0;
class A
{
public:
A()
{
log(100);
log(10,20);
}
void log(int i)
{
cout<<"log"<<i<<endl;
};
void log(long a,long b)
{
cout<<"log a:"<<a<<"b:"<<b<<endl;
};
};
}
void isort(void* p,size_t n,size_t sz,FT cmp)/
/style of C++
{
y=1;
int result=cmp(0,0);
printf("in Isort,result is %d\n",result);
}
void xsort(void* p,size_t n,size_t sz,CFT cmp)
//style of C
{
int result=cmp(0,0);
printf("in Xsort,result is %d\n",result);
}
extern "C" void ysort(void* p,size_t n,size_t sz,FT cmp)
//style of C
{
int result=cmp(0,0);
printf("in Ysort,result is %d\n",result);
}
int compare(const void*,const void*)
//style of C++
{
return 1;
}
extern "C" int ccomp(const void*,const void*)/
/style of C
{
return 0;
}
void f(char* v,int sz)
{
A a;
a.log(1000);
qsort(v,sz,1,&compare);//ok
qsort(v,sz,1,&ccomp);//ok
isort(v,sz,1,&compare);//ok
isort(v,sz,1,&ccomp);//ok
xsort(v,sz,1,&compare);//ok
xsort(v,sz,1,&ccomp);//ok
ysort(v,sz,1,&compare);//ok
ysort(v,sz,1,&ccomp);//ok
}
int main()
{
f(0,0);
return 0;
}