473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

has anyone seen this?

I saw somewhere some code that in a simplified version boils down to the
example below. Could someone explain when one would define a pointer as
that in main() below, and why? Pointers to documents that explain this
will do. Thanks!
class MyClass
{
public:
int x;
};
int main()
{
int MyClass::*px = &MyClass::x;

return 0;
}
Mar 10 '07 #1
2 1461
* Amadeus W.M.:
I saw somewhere some code that in a simplified version boils down to the
example below. Could someone explain when one would define a pointer as
that in main() below, and why? Pointers to documents that explain this
will do. Thanks!
class MyClass
{
public:
int x;
};
int main()
{
int MyClass::*px = &MyClass::x;

return 0;
}
Usually there's no good reason to use pointers to members.

Any pointer to member can be represented instead as a pointer to a
function, like

struct MyClass{ int x; };

int& xMember( MyClass& o ) { return o.x; }

int main()
{
int (*pfx)( MyClass& ) = &xMember;
}

Well, at least I think the "any" holds. Pointer to members are so
rarely used that I can't think of an example where the "any" doesn't
hold. Although such an example may exist.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 10 '07 #2
Amadeus W.M. wrote:
I saw somewhere some code that in a simplified version boils down to the
example below. Could someone explain when one would define a pointer as
that in main() below, and why? Pointers to documents that explain this
will do. Thanks!
Google [C++ faq member pointer]

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Mar 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mart Rogers | last post by:
I have the following problem with an ASP.Net solution and would be grateful for any advice on solving it : I load an existing ASP.NET solution into Visual Studio (2002), then from Solution...
1
by: DickChristoph | last post by:
Hi We have a SQL 2000 (sp3) server with a database that I set up to have the MDF on D: and the LDF on E:. All was going along fine for several months and one day the server rebooted. The SQL log...
0
by: numerous instabilities in deploying VB | last post by:
I have been working on a VB product It is working beautifuly on my XP dev box and my windows 2000 test machines in the lab. When I install at the customer site, I get all kinds of wacky problems...
0
by: Brandon Potter | last post by:
Looking for a good packet capture library in .NET capable of capturing packets (whether natively or through third party/WinPCap, etc.). Or, at least, a library capable of decoding packet...
6
by: --CELKO-- | last post by:
Has anyone seen a 25 TB data warehouse on SQL Server? I do not know of such a thing, but maybe it exists out there.
13
by: penguin732901 | last post by:
Checking back for discussions, there was a lot of talk about 2000 being slower than 97, but not so much lately. What is the latest opinion? Anyone care to set up a poll for how many NG members...
8
by: Wayne Gillespie | last post by:
I have an application in service (A97) which is a booking system for a modelling agency. When they add / edit a job I display a subform which lists all models, filtered according to criteria set by...
3
by: Fredrik Lundh | last post by:
and yes, has anyone seen Aahz or his OSCON2001 thread tutorial slides lately ? as noticed here: http://effbot.org/pyfaq/how-do-i-program-using-threads.htm they have disappeared from the...
2
by: Daz | last post by:
Hi everyone. I would like to find a good JavaScript compactor/obfuscator. Obfuscation is not important to me really, but I would like a compactor that understands variables and functions in a...
15
by: Neil | last post by:
So, I tried to copy a toolbar. I have a custom menu bar for a form. Tried to copy it so that I could modify the copy and use it with another form. With no direct way to copy it, I made a copy of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.