Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Frasncis Glassboro wrote.

Path: g2news2.google.com!postnews.google.com!a10g2000vby.googlegroups.com!not-for-mail
From: James Kanze <james.ka...@gmail.com>
Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c++
Subject: Re: Frasncis Glassboro wrote.
Date: Sat, 8 Jan 2011 07:37:26 -0800 (PST)
Organization: http://groups.google.com
Lines: 65
Message-ID: <6579bbb8-5ddb-46c0-920b-065d697b0ffe@a10g2000vby.googlegroups.com>
References: <O9lVo.36965$ev4.2237@newsfe05.ams2> <4d263f48$0$32136$7b1e8fa0@news.nbl.fi>
 <F1sVo.71884$E44.19430@newsfe30.ams2> <65a55b13-8ec3-49d4-a210-24a53366c4e0@l32g2000yqc.googlegroups.com>
 <d6FVo.39327$B77.23915@newsfe29.ams2> <7148a492-1586-4421-bc6c-4afa38770f53@w29g2000vba.googlegroups.com>
 <ivJVo.6379$155.2167@newsfe15.ams2>
NNTP-Posting-Host: 86.144.56.186
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1294501046 17485 127.0.0.1 (8 Jan 2011 15:37:26 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 8 Jan 2011 15:37:26 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a10g2000vby.googlegroups.com; posting-host=86.144.56.186; posting-account=1W_PtwoAAAA1QoMcl2Z5P6j-DNc8HR3W
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13)
 Gecko/20101203 Firefox/3.6.13,gzip(gfe)

On Jan 7, 7:06 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
> "James Kanze" <james.ka...@gmail.com> wrote in message

> news:7148a492-1586-4421-bc6c-4afa38770f53@w29g2000vba.googlegroups.com...
> > On Jan 7, 2:07 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
> >> "James Kanze" <james.ka...@gmail.com> wrote in message

> >    [...]
> >> >> I can understand the concept you express but
> >> >> a) how do you get the address of a member function?

> >> > &ClassName::functionName

> >> > Concretely:

> >> >    struct C { void f(); };
> >> >    void (C::*pf)() = &C::f;

> >> >> b) what happens if this member function is virtual?

> >> > It works correctly.  That's why pointer to member functions are
> >> > often larger than any other pointer types (but there are other
> >> > ways of solving the problem).

> >> What would your pointer point to ?

> > That's the compiler writers problem, not mine:-).

> It certainly is a problem for the compiler, and perhaps the
> program too.  Especially if you didn't initialised the empty
> pointer.  Let me put it another way, where would you get the
> address for the virtual function?

From the object you call the pointer on.

> >> You cannot do this with virtual functions and  you are wrong
> >> to suggest it works correctly.

> > It does work, and I've done it.  More than once.

> It simply can't be done as the concept of virtual functions
> only lives in the world of objects.  Please show some basic
> code. I guarantee you cannot.

Your guarantees aren't worth much, since you obviously aren't
familiar with C++.  It does work, and I've done it.  Several
types, with different compilers (Sun CC, g++ and VC++, at
least---although you need special compiler options with VC++ if
everything isn't in the same translation unit).

> >> A virtual function calling mechanism requires an object.

> > Using a pointer to a member requires an object.  So?

> The point was to show that a member function can be called
> *without * an object.

Whose point, where and when?  You're just making things up as
you go along, trying to bluff your way out, rather than just
admitting that you really don't know C++.

--
James Kanze