|
From: Jason H. <jas...@bt...> - 2001-10-23 03:32:08
|
I'm glad someone else agrees with me. :) 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). "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. Jason. ----- Original Message -----=20 From: Daniel 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 = >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=20 >of=20 > >member functions - there is one instance of a member function that = is=20 > >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 = >list Dev...@li...=20 >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20 >=20 -------------------------------------------------------------------------= ----- Get your FREE download of MSN Explorer at http://explorer.msn.com _______________________________________________ Dev-cpp-users mailing = list Dev...@li... = https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |