User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 31 Mar 2005, 09:52   #1
Radical Edward
Registered User
 
Join Date: Feb 2002
Location: South Pacific
Posts: 4,911
Radical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriend
proably a simple c++ question

I have a book here on c++ which I am trying to follow, but at one point it swaps the

thing.function();

for

thing->function();

what is the difference?
__________________
I think it's time we blow this scene, get everybody and the stuff together..........

ok 3..... 2..... 1.. let's jam
Radical Edward is offline   Reply With Quote
Unread 31 Mar 2005, 11:30   #2
pablissimo
Henry Kelly
 
pablissimo's Avatar
 
Join Date: Apr 2000
Posts: 7,374
pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.pablissimo has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: proably a simple c++ question

I think -> dereferences first. So if 'thing' is a pointer to some object, thing->function() first deferences the pointer to get the object it points to, then called its function() method on it.

For example, from the MSDN site:
Code:
   // Declare a new object of type Point.
   Point ptOrigin;

   // Member function calls use the . member-selection operator.
   ptOrigin.SetX( 0 );
cf

Code:
   // Declare a pointer to an object of type Point.
   Point *pptCurrent = new Point;

   // Member function calls use the -> member-selection operator.
   pptCurrent->SetX( ptOrigin.GetX() + 10 );
Note the differences between how Point ptOrigin and pptCurrent are defined.
__________________
You're now playing ketchup
pablissimo is offline   Reply With Quote
Unread 31 Mar 2005, 12:13   #3
Radical Edward
Registered User
 
Join Date: Feb 2002
Location: South Pacific
Posts: 4,911
Radical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriendRadical Edward needs a job and a girlfriend
Re: proably a simple c++ question

excellent. thanks
__________________
I think it's time we blow this scene, get everybody and the stuff together..........

ok 3..... 2..... 1.. let's jam
Radical Edward is offline   Reply With Quote
Unread 3 Apr 2005, 16:37   #4
Weeks
Banned
 
Weeks's Avatar
 
Join Date: Jun 2002
Posts: 2,635
Weeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriendWeeks needs a job and a girlfriend
Re: proably a simple c++ question

Yeah what pab said.

1) thing.function(arg);
2) thing->function(arg);

'thing' in 2 is a pointer, 'thing' in 1 isn't.
Weeks is offline   Reply With Quote
Unread 3 Apr 2005, 21:35   #5
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Re: proably a simple c++ question

thing 2 doesn't even have to be a literal pointer, it could just be something that operator-> is defined for. Often an iterator.
queball is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 16:31.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018