Re: [Dev-C++] About member functions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jason H. <jas...@bt...> - 2001-11-01 00:58:39
|
MessageI am not a pro for a start, but because of my background I tend = to understand some of the concepts in Classes and Objects from a = different perspective. My background being as a hardware engineer and = using assembler (68000 mainly). The section you are refering to is about pointers to member functions. = Something that a class can do is provide a table of pointers to it's = member functions in it's internal representation. There will still be = only one instance of the member funstion, but each object will contain a = pointer to that fuction. This is specifically needed in the case of = virtual member functions where the caller doesn't necessarily know what = class it is using. By saying that a particular pointer to the member is = at such and such a position in an object then you can indirectly call = the correct function for the object. Pointers to pointers are a useful = form of indirection. In essence what that paragraph is saying is that if you call method 5 = (for example) of an object the compiler will know that it actualy refers = to a particular function in a particular place in memory, or at least a = pointer to that function in memory. I will qoute from my edition (third) on the same page you quote: "C++ offers a facility for indirectly referring to member of a class. A = pointer to a member is a *value* that identifies a member of a class. = You can think of it as the position of the member in an object of the = class, but of course an implementation takes into account the = differences between data members, virtual functions, non-virtual = functions, etc." Does that seem reasonable to you? It seems that we are looking at the = same paragraphs and getting two totally different answers from it. Jason. ----- Original Message -----=20 From: Ioannis Vranos=20 To: Dev-C++=20 Sent: Wednesday, October 31, 2001 8:11 PM Subject: [Dev-C++] About member functions This subject has been discussed on th e past, but now new evidence = came up. :) In "The C++ Programming Language" Special Edition on page 419 it says = that each object has its own member function as i was claiming in the = beginning. It says many things but lets concentrate at the end of that page: "Just like ordinary pointers to functions, pointers to member = functions are used when we need to refer to a function without having to = know its name. However, a pointer to member isn't a pointer to a piece = of memory the way a pointer to a variable or a pointer to a function is. = It is more like an offfset into a structure or an index into an array. = When a pointer to member is combined with a pointer to an object of the = right type, it yields something that identifies a particular member of a = particular object". i think we were discussing it with Jason Hardman. Jason if you see it, = please tell me your opinion (since you seem you are a pro). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |