Got confused....cant get it......:([?] On Wed, Oct 10, 2012 at 1:00 AM, Prem Krishna Chettri <hprem...@gmail.com>wrote:
> Well Lemme try few more hand here.. > > Basics First Guys :- > > this :- is a hidden pointer to a class (Agree ?). So whats > so special about it.. Answer is its compaction when the object of the class > is being created. Why? Here it goes. As object memory allocation (I hope > everyone knows) have memory structure such that the first parameter always > starts with arg[1]. so why not arg[0] as array always indexes with "0"? The > Answer is here.. Coz every time the object of a class is generated the > Zeroth index is alwayz occupied by this "*this*" pointer. So if do you > follow me up to here properly that you know the significance of this now.. > Coz its object refference lies to the value of offset 0 to the base address > of the class's object, giving the flexibility to express any member of the > class by directly accessing via its base address and this also explains why > this has to be a pointer and not a normal member variable. > > Now here comes the other part of question.why we need *" * > * *this"* where *"this"* should give the base address of the object of > the class we wanna refer. The Answer is partly "YES" coz as we discuss "*this" > *knows almost everything about the class or rather an object of a class > within a class scope but here is the catch we are telling someone to get a > bowl of rice from my private house. So how will he be able to get it? Until > I tell him my house structure, which in programming language like C++ is > reference. > > I am saying sir, I have created a house (object) and here is > the layout (referring to what I have created) so inorder to tell him about > my layout I have to generate the return value which is NOT the house > (object) but the reference to the house ( "pointer" pointing to what I have > created ). > > Now I am almost done here.. So Why " ** this *" and not "*this*" > is coz "*this"* gives the object directly to the the party who is > calling me and the reference means a copy not the object itself whereas " > ** this *" is presenting you what you were looking for. > > I hope now people are clear about all the above aspects.. I mean the > very last question about returns full object or wat?? if you get all this.. > U got all this.. :) > > Ciao, > Prem > > > > > > > On Wed, Oct 10, 2012 at 12:23 AM, rahul sharma <rahul23111...@gmail.com>wrote: > >> @saurabh....if i look from the way that i need to return a referencei.e. >> i mean object...i will ryt *this for this..........i knew >> this............but i have read that reference is a const pointer ....so if >> i look from this prespective then do i need to return >> pointer(this).............. >> int * fun()//return pointer to int >> >> then what does return by reference mean if i return ( *this)..then what >> actually returns...........full object???or pointer to object...mix >> questions ...plz clear me.. >> >> >> On Tue, Oct 9, 2012 at 11:26 PM, Saurabh Kumar <srbh.ku...@gmail.com>wrote: >> >>> >> 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. >>> >> >> -- >> 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. > -- 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.
<<322.png>>