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
Frasncis Glassboro wrote.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 72 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Kanze  
View profile  
 More options Jan 7 2011, 1:34 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Fri, 7 Jan 2011 10:34:15 -0800 (PST)
Local: Fri, Jan 7 2011 1:34 pm
Subject: Re: Frasncis Glassboro wrote.
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:-).

> 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.

> A virtual function calling mechanism requires an object.

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

--
James Kanze


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bart van Ingen Schenau  
View profile  
 More options Jan 7 2011, 1:43 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Bart van Ingen Schenau <b...@ingen.ddns.info>
Date: Fri, 7 Jan 2011 10:43:52 -0800 (PST)
Local: Fri, Jan 7 2011 1:43 pm
Subject: Re: Frasncis Glassboro wrote.
On Jan 7, 3:07 pm, "Paul" <pchris...@yahoo.co.uk> wrote:

The pointer points to the member function.

> You cannot do this with virtual functions and  you are wrong to suggest it
> works correctly.
> A virtual function calling mechanism requires an object.

It is required to work also with virtual member functions. To make
this possible, you have to specify an object when dereferencing the
pointer to a member function.

If I were to implement such pointers, they would consist of the
following:
- A flag indicating if dynamic dispatch (for virtual member functions)
is needed or not, and
- The address of the function, for non-virtual member functions, or
- The offset in the vtable, for virtual functions.

<snip>

> >> And what exactly would 'this' point to?

> > The class object you used in the dereferencing expression.

> A class is not an object.

I will give you this nitpick.

To answer the question again:
'this' points to the object, of class type, that was used in the
dereferencing expression.

> No object was ever declared in your code.

> Once again you appear confused about classes an objects.

To me, it appears more like careless writing.

<snip>

> If you intend using a function as a standalone function why would you define
> it as a member function of an object type. This seems like bad program
> design.

Who is talking about using member functions as stand-alone functions?

Bart v Ingen Schenau


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 2:06 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Fri, 7 Jan 2011 19:06:51 -0000
Local: Fri, Jan 7 2011 2:06 pm
Subject: Re: Frasncis Glassboro wrote.

"James Kanze" <james.ka...@gmail.com> wrote in message

news:7148a492-1586-4421-bc6c-4afa38770f53@w29g2000vba.googlegroups.com...

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?

>> 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.

>> A virtual function calling mechanism requires an object.

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

> --
> James Kanze

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juha Nieminen  
View profile  
 More options Jan 7 2011, 2:49 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Juha Nieminen <nos...@thanks.invalid>
Date: 07 Jan 2011 19:49:46 GMT
Local: Fri, Jan 7 2011 2:49 pm
Subject: Re: Frasncis Glassboro wrote.
In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:

>>  I find it a bit ironic that you protest so loudly abour common concepts
>> of C++ programming, yet you lack such knowledge of the language.

> The fact that you have began your posting with a direct insult to me

  How exactly is it "a direct insult" for me to find your behavior
ironic?

> leaves
> me no other opinion than you are actually nothing more than an other
> clueless idiot who has nothing more than an UNREASONABLE argument to put
> forward.

  What that makes me think is that you are playing the "you insulted me"
card in order to get yourself out of having to actually answer the
objections presented to your claims.

  Perhaps if instead of playing that card you would actually demonstrate
how what I wrote is wrong, we could have a conversation. If you won't,
I can only conclude that you accept my points as valid and have no
response.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juha Nieminen  
View profile  
 More options Jan 7 2011, 2:55 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Juha Nieminen <nos...@thanks.invalid>
Date: 07 Jan 2011 19:55:19 GMT
Local: Fri, Jan 7 2011 2:55 pm
Subject: Re: Frasncis Glassboro wrote.
In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:

  I find it really amusing who you are telling to that he is wrong
about C++.

  If you think that virtual function pointers cannot work, care to give
an example code which demonstrates your claim?

  You know, before making a claim it's usually a good idea to actually
test that the claim is valid.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 3:24 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Fri, 7 Jan 2011 20:24:24 -0000
Local: Fri, Jan 7 2011 3:24 pm
Subject: Re: Frasncis Glassboro wrote.

"Bart van Ingen Schenau" <b...@ingen.ddns.info> wrote in message
news:a39be560-9159-4e83-992c-07c0292c9a27@o4g2000yqd.googlegroups.com...
On Jan 7, 3:07 pm, "Paul" <pchris...@yahoo.co.uk> wrote:

The pointer points to the member function.

> You cannot do this with virtual functions and you are wrong to suggest it
> works correctly.
> A virtual function calling mechanism requires an object.

It is required to work also with virtual member functions. To make
this possible, you have to specify an object when dereferencing the
pointer to a member function.

If I were to implement such pointers, they would consist of the
following:
- A flag indicating if dynamic dispatch (for virtual member functions)
is needed or not, and
- The address of the function, for non-virtual member functions, or
- The offset in the vtable, for virtual functions.

<snip>

> >> And what exactly would 'this' point to?

> > The class object you used in the dereferencing expression.

> A class is not an object.

I will give you this nitpick.

To answer the question again:
'this' points to the object, of class type, that was used in the
dereferencing expression.

> No object was ever declared in your code.

> Once again you appear confused about classes an objects.

To me, it appears more like careless writing.

<snip>

> If you intend using a function as a standalone function why would you
> define
> it as a member function of an object type. This seems like bad program
> design.

Who is talking about using member functions as stand-alone functions?

Bart v Ingen Schenau
.........................................................................

I thought that was the whole point of their argument...
To express the use of a member function , without it being connected to an
object.?

If this is not the case maybe I missed something.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 4:15 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Fri, 7 Jan 2011 21:15:56 -0000
Local: Fri, Jan 7 2011 4:15 pm
Subject: Re: Frasncis Glassboro wrote.

"Juha Nieminen" <nos...@thanks.invalid> wrote in message

news:4d276e5a$0$12283$7b1e8fa0@news.nbl.fi...

> In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:
>>>  I find it a bit ironic that you protest so loudly abour common concepts
>>> of C++ programming, yet you lack such knowledge of the language.

>> The fact that you have began your posting with a direct insult to me

>  How exactly is it "a direct insult" for me to find your behavior
> ironic?

What part of "you lack such knowlege of the language" do you not understand
to be an insult?

Don't bother replying because I'll just tell ya to fuck off anyway.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 4:21 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Fri, 7 Jan 2011 21:21:47 -0000
Local: Fri, Jan 7 2011 4:21 pm
Subject: Re: Frasncis Glassboro wrote.

"Juha Nieminen" <nos...@thanks.invalid> wrote in message

news:4d276fa7$0$12283$7b1e8fa0@news.nbl.fi...

I am not 'claiming' they don't work without objects , I am *telling* you
they don't.

The onus is on you to show us an example of using a virtual function without
an object, since you think it works.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Garrett Hartshaw  
View profile  
 More options Jan 7 2011, 5:47 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Garrett Hartshaw <gharts...@gmail.com>
Date: Fri, 07 Jan 2011 17:47:12 -0500
Local: Fri, Jan 7 2011 5:47 pm
Subject: Re: Frasncis Glassboro wrote.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/07/2011 02:06 PM, Paul wrote:

#include <iostream>

class C1 {
public:
    virtual void f() {
        std::cout << "C1::f" << std::endl;
    }

};

class C2 : public C1 {
public:
    virtual void f() {
        std::cout << "C2::f" << std::endl;
    }

};

int main () {
  void (C1::*p)() = &C1::f; //create a pointer to a member function

  C1 a;                         //create a object of type C1
  C1 * b;                       //create a object of type pointer to C1
  b = new C2();                 //allocate a object of type C2

  (a.*p)();                     //call the member function pointed to
                                //by p, with &a as this
  (b->*p)();                    //call the member function pointed to
                                //by p (virtually), with b as this

  return 0;

}

This code prints the following.

C1::f
C2::f
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNJ5fwAAoJEO0SzzQOdchN7x0P/j9jO/ptm/i8ir1LzUI9WhpN
P1n/A3rjYALl3i6oj/+MzE91+yuWcPgA0raXHnHITUDldfg9IdDXq0x8M/hDupWG
nrvGCOEmkXmHWn6cw6lMgGS9TlGtyvWcR9wcDAAC2Zq/b6NcctSWKWbWhSOiJ5Im
zC3mx0b4n+lh22S78nCHLy+9Nsx2+3Czmrwjo5D6X4kI4uUQ837NwMuEIf0w5Wlt
rDCxg0/694yukocZomnaOveZJNt8GXVcwrQQEdI4o87CVGTKWLLNLzXN8F8Aa7vr
QpdZrL8U7PyTBofQNoHUzFJDuIkBno7zWGNR7Y3Ql9yu8fhx9MHubTvv4mfUrTab
gM5vj2HmLI00EflOhpczx1EN9McBvWOga+CPoetzf0ovauO/n2aOjhrAkeGMYKZY
dmVmrSyhXnCaGw2SfhWduRn2aY/yMOUdEoT28/MFI1ruNWj6DKyOtvJiKm3MB3Za
+5u5yO/XH2+CZIpXhCEQrYi6wwIAzv1pfMGhUV2tylO/ZSiP0toItZr3vm7JuBEK
8TSs+KvmLeJ+97XmThfPoPWMThHfLXmLqy/3WasmvDkTdiIrI1brf0gugQuAugHw
xjfcfzrRGtm6yaL8CSlAlqb/vmJiafi8m6Qjju1WuJTtaS+YQGAP5gAdQ2a2W3/S
FbMuQtdtJm6baWiB455Z
=u89w
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stan  
View profile  
 More options Jan 7 2011, 5:47 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: stan <smo...@exis.net>
Date: Fri, 7 Jan 2011 17:47:22 -0500
Local: Fri, Jan 7 2011 5:47 pm
Subject: Re: Frasncis Glassboro wrote.

Paul wrote:
> "Juha Nieminen" <nos...@thanks.invalid> wrote in message
<snip>
>>  I find it a bit ironic that you protest so loudly abour common concepts
>> of C++ programming, yet you lack such knowledge of the language.

> The fact that you have began your posting with a direct insult to me leaves
> me no other opinion than you are actually nothing more than an other
> clueless idiot who has nothing more than an UNREASONABLE argument to put
> forward.

"No other opinion" would seem to suggest that our opinions, or more
precisely your ability to form an opinion, are limited.  I find that
somewhat surprising because your performance to date suggests that you
are indeed exceptionally skilled at forming very strong opinions. You
have persistently denied any limits to your abilities or knowledge,
yet here you appear to concede a minor point. Typo?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 8:55 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Sat, 8 Jan 2011 01:55:20 -0000
Local: Fri, Jan 7 2011 8:55 pm
Subject: Re: Frasncis Glassboro wrote.

"Garrett Hartshaw" <gharts...@gmail.com> wrote in message

news:ig855p$ec1$1@speranza.aioe.org...

The challenge put forward was to invoke a virtual function without creating
an object. Here you have created an object.
I applaud your abilities nonetheless, assuming the code is correct.

>  b = new C2(); //allocate a object of type C2

>  (a.*p)(); //call the member function pointed to
>                                //by p, with &a as this
>  (b->*p)();                    //call the member function pointed to
>                                //by p (virtually), with b as this

>  return 0;
> }

> This code prints the following.

> C1::f
> C2::f

The very nature of virtual functions require objects and perhaps you have
demostrated this.
This was what i was referring when I initially stated 'it won't work with
virtual functions':

 "You can take the address of a member function (and assign it to a
function pointer of the proper type), and it will *not* be tied to any
specific object."


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stan  
View profile  
 More options Jan 7 2011, 9:23 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: stan <smo...@exis.net>
Date: Fri, 7 Jan 2011 21:23:11 -0500
Local: Fri, Jan 7 2011 9:23 pm
Subject: Re: Frasncis Glassboro wrote.

Control issues?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stan  
View profile  
 More options Jan 7 2011, 9:28 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: stan <smo...@exis.net>
Date: Fri, 7 Jan 2011 21:28:08 -0500
Local: Fri, Jan 7 2011 9:28 pm
Subject: Re: Frasncis Glassboro wrote.

Garrett Hartshaw wrote:
> On 01/07/2011 02:06 PM, Paul wrote:

<snip>

Did you hear that? Sounded like "I'm mmeelllllllttttting"

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Garrett Hartshaw  
View profile  
 More options Jan 7 2011, 9:55 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Garrett Hartshaw <gharts...@gmail.com>
Date: Fri, 07 Jan 2011 21:55:59 -0500
Local: Fri, Jan 7 2011 9:55 pm
Subject: Re: Frasncis Glassboro wrote.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/07/2011 08:55 PM, Paul wrote:

The (virtual) member function was *not* tied to a specific object, as it
(the same function) was used by two different objects. If it was *a part
of* the object, you would not be able to have a pointer to it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNJ9I/AAoJEO0SzzQOdchNNt8QAIt7B8Hfsc+2iYiN1wanHNxQ
2rWmra66snapd+37ZO3efBkuaBEpggJrwiGYr7zmRV6+kmGSff0f5HoITBQxv0wP
IR9AahmQdD0bBRDpMXFM+W2TW/2BFCIfYxxNkHe7PZaiKYOhSCBsIcOEH7kc87YZ
dOYVtdEYQrLVyBF+cJhIZgCt8zfbhMUi24c0qwrdsC/ZLdTmWfPqnCRKgUw5bcuy
3UPygLpq+9LEsUUzW/VpG/CnNGj6Ftke+2xXVJFcJsEtb8YWQLHJEy0F3xqRperP
HBN5Bt1kiLN/NBmy9d+3nUsvBf5T6PHGtoPvgABIOORD2uUD+8Nk1bpKqHvYN6O8
pXRUdnkdRhiAPpjNKpAQ9ofcnkwbHbyq5+clEPCdf734vuea2aK+Llt8rLFcEqsC
w5NDbrQ5/4lFxQPRushBZqxDaSgCW33w+YEtBmrQIx8BYC63Dx6sDPKyQBfgBZDj
xr/Os/y1zPVFQS3waG5a+GO2bsduUqFBVNNkoFmvvIqeXoES/hUTrkfmD6T8UasY
dSbwihNm+QL8Tx/iNQ95KwWC5C6XrOrgXfR23DwbQOtw6Sehzcx7pldE/O9F4GAF
a98GPBZd1gat4m6ON+oj68yOudXJurjjDEb+s2DQHgwHgasIld1LMoy+IbXtBosT
twwDeuyGBgd0PRLaOi7e
=d+WZ
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 7 2011, 11:35 pm
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Sat, 8 Jan 2011 04:35:45 -0000
Local: Fri, Jan 7 2011 11:35 pm
Subject: Re: Frasncis Glassboro wrote.

"Garrett Hartshaw" <gharts...@gmail.com> wrote in message

news:ig8jo6$age$1@speranza.aioe.org...

With:
(a.*p)(); //call the member function pointed to by p, with &a as this
(b->*p)();    //call the member function pointed to by p (virtually), with b
as this

There are two functions here.
As I understand it you seem to think there is only one function . ????


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Garrett Hartshaw  
View profile  
 More options Jan 8 2011, 12:09 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Garrett Hartshaw <gharts...@gmail.com>
Date: Sat, 08 Jan 2011 00:09:00 -0500
Subject: Re: Frasncis Glassboro wrote.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/07/2011 11:35 PM, Paul wrote:

Ok, there are two functions, C1::f and C2::f, and the pointer really
points to an offset into a vtable (the vtable being part of the object),
which contains the address of the function actually called (not part of
the object). However, if we had another object of (dynamic) type C2
(e.g. C1 * c = new C2(); ), and call the function  ( (c->*p)(); ), then
we have 3 objects ( a, b, c ), and only 2 functions ( C1::f, and C2::f
). This would not be possible if the function itself was part of the object.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNJ/FsAAoJEO0SzzQOdchNkDAP/1Grv4JS8ytSK9QwAC5LYzRg
rAIIUWTmqfffisXZDP4URiJ6tXxu2FPcBtibr11q3s1xj96EKU08Wq3HsejeIsxk
r85Zu4WFIg1mo9VbOCd89Dqmt1TH1nqV1jyNB3H2Bj3fl5ZffAY0oIpwRSs1rRQi
dh2qurUz0ZLe3YY3Md4GNXqKqlBHH0eJm6Hagp6pzuqsRLNmCyxXFU8bxNzZJ3iX
eMAnZuLPMoKgK88LKx4h48eAp12HU1E1YZ9ycEeRp9Id/EFo3Ia1os5VGTacVHjw
tA7bZl/FDJEq21KCrRP7CZzdPLY6VIqzmN5EB6LprFfDE+7NDR2V+AxJ7P7KX9DR
3G+Tml/K2IPu7rhKc2Of4JlTfpFtBO22vX10g3GxmfIqKZpyeCyuug7CaaR+1DYI
ZcxxdnQLiFB7M6npTlLg8GiXNwO5DBXDMPcV8U9ZqEw0DJ/chOcLJxfnFR5/4RfQ
lufFSTI1vdpUlck4F7+wvPkJAHnWeNXW33DSYjlznMH8MbI4a5TkzhK1SnoK31rb
CVSizXZqo0j85cb3NxDTIA7nU+A4Zi5JAyBkeT0So1ThwmtgVIKwUTWCUz7c/8kU
Yz2IOHschxQtm2b8BUu4HoHPoVWcbpO3lWQflHKTHSZNm8l8hz8GSF0rGDIZxjXi
51WvaYzdoWQSJfrBNkNM
=d/p5
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juha Nieminen  
View profile  
 More options Jan 8 2011, 3:32 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Juha Nieminen <nos...@thanks.invalid>
Date: 08 Jan 2011 08:32:45 GMT
Local: Sat, Jan 8 2011 3:32 am
Subject: Re: Frasncis Glassboro wrote.
In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:

> "Juha Nieminen" <nos...@thanks.invalid> wrote in message
> news:4d276e5a$0$12283$7b1e8fa0@news.nbl.fi...
>> In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:
>>>>  I find it a bit ironic that you protest so loudly abour common concepts
>>>> of C++ programming, yet you lack such knowledge of the language.

>>> The fact that you have began your posting with a direct insult to me

>>  How exactly is it "a direct insult" for me to find your behavior
>> ironic?

> What part of "you lack such knowlege of the language" do you not understand
> to be an insult?

  If someone told me that I lack knowledge on quantum mechanics, which is
absolutely true, why would I feel insulted? I *do* lack a lot of knowledge
about quantum mechanics. Someone stating so, especially after I openly have
admitted so, would simply be telling the truth. Where exactly is the insult?

  You clearly stated that you don't know about member function pointers.
Hence, rather obviously, you lack knowledge about them. Hence what I said
was a true statement.

> Don't bother replying because I'll just tell ya to fuck off anyway.

  You are still trying to play the "you insulted me" card, probably so
that you don't have to discuss the actual arguments presented.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juha Nieminen  
View profile  
 More options Jan 8 2011, 3:42 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Juha Nieminen <nos...@thanks.invalid>
Date: 08 Jan 2011 08:42:14 GMT
Local: Sat, Jan 8 2011 3:42 am
Subject: Re: Frasncis Glassboro wrote.
In comp.lang.c++ Paul <pchris...@yahoo.co.uk> wrote:

  Now you are changing your claim. You claimed in your earlier post that
"virtual function pointers cannot work", without mentioning anything about
objects. Now you are moving the goalposts and changing the claim to
"virtual function pointers cannot be called without an object", which is
a completely different statement.

  If you actually *read* what I wrote earlier, I gave you the exact syntax
of how you can create a member function pointer and how you call it with
an object. Nobody claimed that you can *call* the function without an
object. What I said was that you can refer to a member function (in other
words, take its address and assign it to a pointer) without an object,
which would indicate that the function is not, in fact, tied to any
specific object, but a free function which is only tied to a specific
*class*. The function in question takes implicitly an object as
parameter, which is why you have to supply one when you call it (while
the syntax for this is special, it's in principle no different from
calling a regular function which takes an object as parameter in the
regular way).

  In other words, there's little difference between this:

    class A { public: void foo(); };

and this:

    class A {};
    void foo(A*);

  (The major difference is the scope in which 'foo' is declared. In the
former case 'foo' is specifically tied to the scope of A.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rui Maciel  
View profile  
 More options Jan 8 2011, 9:13 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
Followup-To: alt.comp.lang.learn.c-c++
From: Rui Maciel <rui.mac...@gmail.com>
Date: Sat, 08 Jan 2011 14:13:35 +0000
Local: Sat, Jan 8 2011 9:13 am
Subject: Re: Frasncis Glassboro wrote.

Paul wrote:
> I am not 'claiming' they don't work without objects , I am *telling* you
> they don't.

> The onus is on you to show us an example of using a virtual function
> without an object, since you think it works.

You got it backwards.  If you claim that they don't work then you are
responsible to provide a concrete case where they don't work, so that
those interested in helping you can analyse your example and, from there,
provide an answer.

Rui Maciel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 8 2011, 10:00 am
Newsgroups: alt.comp.lang.learn.c-c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Sat, 8 Jan 2011 15:00:57 -0000
Local: Sat, Jan 8 2011 10:00 am
Subject: Re: Frasncis Glassboro wrote.

"Rui Maciel" <rui.mac...@gmail.com> wrote in message

news:4d28710e$0$8918$a729d347@news.telepac.pt...

A virtual function is an OOP mechanism that is generally considered to
object related.
The fact that someone has *claimed* they can be used without the prescence
of an objcet does no tmean I have to prove otherwise.

The only thing *backwards* here completely incorrect interpretation..


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Jan 8 2011, 10:37 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Sat, 8 Jan 2011 07:37:26 -0800 (PST)
Local: Sat, Jan 8 2011 10:37 am
Subject: Re: Frasncis Glassboro wrote.
On Jan 7, 7:06 pm, "Paul" <pchris...@yahoo.co.uk> wrote:

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Jan 8 2011, 10:40 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Sat, 8 Jan 2011 07:40:41 -0800 (PST)
Local: Sat, Jan 8 2011 10:40 am
Subject: Re: Frasncis Glassboro wrote.
On Jan 8, 5:09 am, Garrett Hartshaw <gharts...@gmail.com> wrote:

> On 01/07/2011 11:35 PM, Paul wrote:

    [...]

> > With:
> > (a.*p)(); //call the member function pointed to by p, with &a as this
> > (b->*p)();    //call the member function pointed to by p (virtually),
> > with b as this
> > There are two functions here.
> > As I understand it you seem to think there is only one function . ????
> Ok, there are two functions, C1::f and C2::f, and the pointer really
> points to an offset into a vtable (the vtable being part of the object),
> which contains the address of the function actually called (not part of
> the object).

Maybe.  That's one implementation technique.  In other
implementations, the pointer actually points to some other
function entirely, which then makes the virtual function call.

The important thing, I think, is that these functions (however
many) live independently of any objects.

--
James Kanze


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 8 2011, 11:07 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: "Paul" <pchris...@yahoo.co.uk>
Date: Sat, 8 Jan 2011 16:07:50 -0000
Local: Sat, Jan 8 2011 11:07 am
Subject: Re: Frasncis Glassboro wrote.

"Garrett Hartshaw" <gharts...@gmail.com> wrote in message

news:ig8rhp$qtj$1@speranza.aioe.org...

No, you cannot use a virtual function without an object.
A virtual  function is basically a pointer that exists within an object, a
virtual function never actually exists as a function hence *virtual*
function.
It is impossible to invoke a virtual function without the existence of an
object. The object contains the pointer (that is the virtual function).

Hope this makes sense to you.
Some peope are obviously confused between a precompile time entity(class)
and an object.
A function is not contained within a class anymore than it is contained
within an object, with:
wanda.blowBubbles();
This statement contains an object and a member function, there is no class
here. This member function does not exist until it's invoked on an object.
The function is exclusively tied to the object, (*not the class*), the class
is stored on some file on an old dusty computer on the other side of the
world.
After the code is compiled a class no longer exists , a class is a
precompile time entity in C++, a class in C++ is not the same as Java class.

I don't know what is wrong these people who cannot understand this , they
are obviously very very ignorant and confused, please don't be one of them


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leigh Johnston  
View profile  
 More options Jan 8 2011, 11:16 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Leigh Johnston <le...@i42.co.uk>
Date: Sat, 08 Jan 2011 16:16:38 +0000
Local: Sat, Jan 8 2011 11:16 am
Subject: Re: Frasncis Glassboro wrote.
On 08/01/2011 16:07, Paul wrote:

You are wrong yet again; you obviously do not know C++.  The address of
a virtual function is contained within a vtable; it doesn't exist within
an object; all that exists within an object is a pointer to the vtable
if the object is of class type and the class contains at least one
virtual function.  Objects do not contain member functions (virtual or
not); classes contain member functions (virtual or not).

> Hope this makes sense to you.
> Some peope are obviously confused between a precompile time
> entity(class) and an object.
> A function is not contained within a class anymore than it is contained
> within an object, with:
> wanda.blowBubbles();
> This statement contains an object and a member function, there is no
> class here. This member function does not exist until it's invoked on an

Wrong yet again; member functions exist within the code segment before
any objects are created at runtime.

> object. The function is exclusively tied to the object, (*not the
> class*), the class is stored on some file on an old dusty computer on
> the other side of the world.
> After the code is compiled a class no longer exists , a class is a
> precompile time entity in C++, a class in C++ is not the same as Java
> class.

> I don't know what is wrong these people who cannot understand this ,
> they are obviously very very ignorant and confused, please don't be one
> of them

I suggest you read a C++ book or two and stop trolling your ignorance in
this newsgroup wasting people's time.

/Leigh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leigh Johnston  
View profile  
 More options Jan 8 2011, 11:25 am
Newsgroups: alt.comp.lang.learn.c-c++, comp.lang.c++
From: Leigh Johnston <le...@i42.co.uk>
Date: Sat, 08 Jan 2011 16:25:52 +0000
Local: Sat, Jan 8 2011 11:25 am
Subject: Re: Frasncis Glassboro wrote.
On 08/01/2011 16:16, Leigh Johnston wrote:

It is important to note however that the use of vtables is an
implementaiton specific way of doing things (vtables are not mentioned
by the standard AFAIK).  I do not know of any implementations that do
not use vtables however; this is down to the fact that the vtable
solution to the problem of dynamic dispatch is efficient and not memory
intensive (requiring only a single pointer in an object when using
single inheritance).

/Leigh


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 26 - 50 of 72 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »