|
From: Jason H. <jas...@bt...> - 2001-10-23 03:11:58
|
I do not see how that passage would prove that each object has it's own copy of a member fuction. In fact the oposite: 'A class member function always "knows" for which object it was invoked', which implies that there is one function and it is made aware of the specific object it is being used upon. BTW I don't have a special edition, but I do have the third edition of Stroustrup. As for the creation of the variable, there is a distinction between the creation of the space for the variable and the initialisation of it. What you are doing in your code is writing to where the compiler thinks the variable should be, even though for that object it hasn't been defined in memory. Technically you are writing to unallocated memory. If the variables were bigger then you would risk overwriting into something else, or causing an access violation. Jason. ----- Original Message ----- From: "Ioannis Vranos" <no...@ya...> To: "Dev-C++" <dev...@li...> Sent: Monday, October 22, 2001 1:29 PM Subject: RE: [Dev-C++] Strange effect If i recall correctly, you have Special Edition. Take a look at 10.2.1 on page 224. But if you notice in my examples even wrong data members are being created! Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Jason Hardman > Sent: Monday, October 22, 2001 12:10 AM > To: Dev-C++ > Subject: Re: [Dev-C++] Strange effect > > > Is this just your belief or can you prove that this is the > case from some external referece or knowledgable party (other > than yourself)? > > As I have been given to understand it the case of there only > being one set of methods existing in memory for a class, and > then each method being passed a hidden pointer to the object > is the true case. Hence the existence of the "this" pointer > for use in a class. I would also like to mention that the way > you would have it is unecessarily wasteful of resources. The > issue becomes more complex with virtual methods and such, but > I won't go into that right now. > > I wouldn't mind if someone else who is reading this > discussion, and is knowledgable about the subject, putting us > both on the correct path. > > Jason. > > ----- Original Message ----- > From: "Ioannis Vranos" <no...@ya...> > To: "Dev-C++" <dev...@li...> > Sent: Sunday, October 21, 2001 3:14 PM > Subject: RE: [Dev-C++] Strange effect > > > Yes, when we create an object all member functions are being > (re)created for that particual object. > > > > >do you believe that there are only a single set of methods for every > object of a type, and the objects only contain the data? > > > No. > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |