[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: pointer to function



> > > Hi
> > > can a function return a pointer to itself ?
> >
> > Yep. Why not??
> 
> This is bit confusing. if yes can you pl. explain with an ex.  What I feel
> is that this will lead to a fatal recursion , when used in a program. Let
> me know if i have mistaken

OK. I understand that trying to declare a function that actually returns a
pointer to itself will be nasty. When I first replied, I was looking at
the effect you may want to achieve. You can declare the func to return
void *, and then return a pointer to itself casted to void *. The caller
can recast the thing and use it.

BTW, why do you need to do this? The caller can always knows pointer to a
function it is calling. What is the point in making the function
explicitly returning it??

	Kedar.
----------------------------------------------------------------
Kedar N. Patankar.
Senior Software Engineer.
ishoni Networks
...Broadband for everyone
http://www.ishoni.com
email - kedar@xxxxxxxxxx
Phone: +91-80-2292125 (Work)
Fax: +91-80-2995545 (Work)
----------------------------------------------------------------
Don't worry over what other people are thinking about you.
They're too busy worrying over what you are thinking about them.