>> as we know reference is a const pointer That is Not quite true. >> our aim is ony to return pointer to circle No. our aim is to return a reference to circle.
When you've to define a reference you do something like: *Circle &ref = c;* you *don't* do: *Circle &ref = &c;* Right ? Same is the case here, at the receiving end where the call was initiated a reference is waiting there to be initialized, so you pass the Object (*this) itself and NOT the pointer (this). [Also remember if you've a complex object, no copy constructors etc. are called when an object is sent for *reference receiving,* so no need of worries there.] References are not quite exactly same as pointers, they were introduced much later as a wrapper to pointers but there are some subtle differences between them when it comes to writing code, behaviorally, yes they are more or less the same. On 9 October 2012 22:54, SAMM <somnath.nit...@gmail.com> wrote: > This used for the following situation when a=b=c=d (Consider then as > the objects of a particular class say X ). > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.