Re: strang function pointer from faq book (help)

From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 03/30/05


Date: Wed, 30 Mar 2005 10:36:22 +0200

tomailmelookatbottom@rediffmail.com wrote:
>
> [my Q and your answer sniped...]
>
> > says:
> > FredMemberPt is an alias name for a data type. This data type is a
>
> > pointer to a member function of Fred, and it takes an int as
> argument
> ^^^^^^^^^^^^^^^^^^^^^^^
> > and returns void.
>
> But I don't find any member function called FredMemberpt in the class
> Fred.All my doubts starts there.Pls explain.

As said: The typedef defines a 'data type name'.
I don't know why you constantly search for a member function
called 'FredMemberPt' in Fred. The compiler doesn't spend a
millisecond to search for one, because the typedef does a completely
different thing: It defines a name for a specific data type. Nothing
more, nothing less.
The data type is: Pointer to member function in Fred, which takes an
int and returns void.
And the name given to that data type is: FredMemberPt

It is like a shortcut for you, the programmer. Such that you don't
have to constantly have to type that beast all over again, but can
use a shorter (and more readable name for it).

Consider:
Your program has to work with arrays of 'long unsigned int' all over
the places. Eg.

int main()
{
  long unsigned int a[20][40];

  ...
}

Now you get tired of typing this monster all the time. Thus you define
a typedef for it:

typedef long unsigned int UIntAr[20][40];

which makes UIntAr a second name for the data type 'long unsigned int [20][40]'.

Then you can write:

int main()
{
  UIntAr a;

  ...
}

That's what typedef does. While in the above array example it isn't such a good
idea, the typedef is a very good idea in the case of function pointers.

-- 
Karl Heinz Buchegger
kbuchegg@gascad.at


Relevant Pages

  • Re: RW error (was: Discussions of COBOL philospphy
    ... When the software was written, in the late '90s, typedef was supported by ... A user-defined data type is defined by specifying a level-01 entry containing ... TYPEDEF clause; all entries that are subordinate to the level-01 entry are ...
    (comp.lang.cobol)
  • Re: RW error (was: Discussions of COBOL philospphy
    ... When the software was written, in the late '90s, typedef was supported by ... A user-defined data type is defined by specifying a level-01 entry containing the ... TYPEDEF clause; all entries that are subordinate to the level-01 entry are considered ...
    (comp.lang.cobol)
  • Re: strang function pointer from faq book (help)
    ... > pointer to a function which is typedef ed. ... It is just an ordinary typedef. ... then MyJ gets an alias for the whole data type, in this case for 'int'. ...
    (comp.lang.cpp)
  • Re: BYTE and DWORD
    ... > typedef DWORD ... I entered 'data type' in the search, ... You can keep typing to refine the menu. ...
    (comp.sys.mac.programmer.help)
  • Re: template programming in CEPB?
    ... > template ... > // data type ... > typedef ST SubjectType; ...
    (microsoft.public.windowsce.platbuilder)