🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #323

Re: why (ptr ->* funcPtr) () and not (ptr -> *funcPtr) () ?

#323
From: Mike Wahler
Date: Fri, 14 Jul 2000 00:00
32 lines
1806 bytes
kristofer stenberg <kristofer.stenberg@chello.se> wrote in message
news:daLb5.765$u21.189364@nntp1.chello.se...
> Say I have an object Dog and a method Dog::run().
> ptr is a pointer to Dog and funcPtr is pointer to run(). First I try to
call
> run() with (ptr ->*   funcPtr) () and it works fine. Then I try (ptr ->
> *funcPtr) ()
> and its an error. A space between -> and * shouldnt make a difference,
> should it?

Yes it does.  ->* is a *single* operator (pointer-to-member dereference,
via a pointer to the type having the member).  Putting a space between
-> and * means they're separate operators, in which case, their being
adjacent is syntactically wrong.

Also, .* is a *single* operator (pointer-to-member dereference,
via an object of the type having the member)

Dog fido;
Dog *pf = &fido;
fido.*funcPtr();
pf->*funcPtr();

With the statement:
pf-> *funcPtr();

pf-> means I want to select a particular member (by name),
and '*funcPtr' certainly isn't one, so you'll probably get a
syntax error.

-Mike
Technical Details
Message-ID: <8ko1cs$fof$1@slb2.atl.mindspring.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <daLb5.765$u21.189364@nntp1.chello.se>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,3b2a10a91b8e07af
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 114592,3b2a10a91b8e07af
X-Google-Attributes: gid114592,public
From: "Mike Wahler" <mkwahler@mkwahler.net>
Subject: Re: why (ptr ->* funcPtr) () and not (ptr -> *funcPtr) () ?
Date: 2000/07/14
Message-ID: <8ko1cs$fof$1@slb2.atl.mindspring.net>
X-Deja-AN: 646487564
References: <daLb5.765$u21.189364@nntp1.chello.se>
X-Priority: 3
X-Server-Date: 14 Jul 2000 21:40:44 GMT
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Organization: MindSpring Enterprises
X-MSMail-Priority: Normal
Reply-To: "Mike Wahler" <mkwahler@ix.netcom.com>
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language