Is it possible in C++ to write a function that returns a pointer to itself?
If no, suggest some other solution to make the following syntax work:
som
Of course it is possible, just look the following code:
#include
typedef void * (*func)();
void * test()
{
printf("this is test\n");
return (void *)&test;
}
int main()
{
(*(func)test())();
}
The result is :
user@linux:~/work/test> gcc test_func.cc -o test
user@linux:~/work/test> ./test
this is test
this is test