Function returning pointer to itself?

Viewed 5564

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:

some_type f ()
{
    static int cnt = 1;
    std::cout << cnt++ << std::endl;
}
int main ()
{
    f()()()...(); // n calls
}

This must print all the numbers from 1 to n.

4 Answers
Related