|
From: Ioannis V. <no...@ya...> - 2001-10-23 08:36:53
|
Finally i agree with you. You are right, every member function has only one instance. I understood it indirectly, from the way pointers to member functions work. Well although i thought i know much about C++, probably there are details i miss. :) =20 =20 =20 Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys =20 -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Jason Hardman Sent: Tuesday, October 23, 2001 5:32 AM To: Dev-C++ Subject: Re: [Dev-C++] Strange effect I'm glad someone else agrees with me. :) =20 Now onto the static issue, "In C++, when static is used on a class *data* member, it causes only one copy of that member to be shared by all objects of its class", (C/C++ Programmer's Reference, second edition - Herbert Schildt). =20 "Member functions may also be declared as static. There are several restrictions placed on static member functions. They may only directly refer to other static members of the class. (Of course, global functions and data my be accessed by static member functions.) A static member function does not have a this pointer....", (C++ The Complete Reference, Third Edition - Herbert Schildt, p.315). The reason that a static member can't access non-static members is because it doesn't have a this pointer and has no frame of reference to get to the data, but a static data member is a single defined instance which therefore has a specific place in memory that can be directly refered to. There still only needs to be one copy of the member function. In the end a static member is a special case used to overcome specific problems. =20 Jason. =20 =20 ----- Original Message -----=20 From: Daniel <mailto:sp...@ho...> Glenfield=20 To: dev...@li...=20 Sent: Monday, October 22, 2001 9:48 PM Subject: RE: [Dev-C++] Strange effect objects have their own data members, they share the member functions in the class they are a part of. They do not have their own functions, this I am sure of. >From: "Ioannis Vranos"=20 >To: "Dev-C++"=20 >Subject: RE: [Dev-C++] Strange effect=20 >Date: Mon, 22 Oct 2001 23:43:25 +0200=20 >=20 >:) That every object has its own data members whhich these functions=20 >manipulate. Except of that, for what static data members and static=20 >member functions exist for?=20 >=20 >=20 >=20 >Ioannis=20 >=20 >* Ioannis Vranos=20 >* Programming pages: http://www.noicys.f2s.com=20 >=20 >* Alternative URL: http://run.to/noicys=20 >=20 >-----Original Message-----=20 >From: dev...@li...=20 >[mailto:dev...@li...] On Behalf Of Daniel=20 >Glenfield=20 >Sent: Monday, October 22, 2001 10:30 PM=20 >To: dev...@li...=20 >Subject: RE: [Dev-C++] Strange effect=20 >=20 >=20 >=20 >I am 100% certain that each object does NOT have it's own copy of the=20 >member functions. What reason would there be?=20 >=20 >=20 >=20 > >From: "Ioannis Vranos"=20 > >To: "Dev-C++"=20 > >Subject: RE: [Dev-C++] Strange effect=20 > >Date: Mon, 22 Oct 2001 22:44:21 +0200=20 > >=20 > >I do not think this is true. Every object has its own member functions.=20 >=20 > >Except of that, here wrong data members are being created too.=20 > >=20 > >=20 > >Ioannis=20 > >=20 > >* Ioannis Vranos=20 > >* Programming pages: http://www.noicys.f2s.com=20 > >=20 > >* Alternative URL: http://run.to/noicys=20 > >=20 > >=20 > >-----Original Message-----=20 > >From: dev...@li...=20 > >[mailto:dev...@li...] On Behalf Of Daniel=20 > >Glenfield=20 > >Sent: Monday, October 22, 2001 7:56 PM=20 > >To: dev...@li...=20 > >Subject: RE: [Dev-C++] Strange effect=20 > >=20 > >=20 > >=20 > >An object holds it's own data members but does not have it's own copy >of=20 > >member functions - there is one instance of a member function that is > >used by all (since it does not change, while data members do).=20 > >=20 >=20 > _____=20 >=20 >Get your FREE download of MSN Explorer at http://explorer.msn.com=20 >=20 >_______________________________________________ Dev-cpp-users mailing=20 >list Dev...@li...=20 >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20 >=20 _____ =20 Get your FREE download of MSN Explorer at http://explorer.msn.com <http://go.msn.com/bql/hmtag_itl_EN.asp>=20 _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |