• Advertisement

Archived

This topic is now archived and is closed to further replies.

Question on stuff.

This topic is 5306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Question on stuff

...hmm, couldn''t be much more vague with that subject line.


what does -> mean???

It depends on the context...

In C++ it is the operator for indirect member access, i.e. it is used to access a struct or class member when the object on the left of it is a pointer, rather than an actual object name.

In ASCII art I suspect it represents an alligator eating a stick of gum.

Share this post


Link to post
Share on other sites
-> references part of a class/structure, I think.

If I had a class named Cheese with a public character variable named "color", I could call access like this. (I think)

Cheese cheddar; //make object of class Cheese named cheddar

cheddar->color="yellow"; //assign the color variable of the cheddar object to "yellow"


Im pretty sure this is right, I am a newb however, so you probably want to get varification on this

Share this post


Link to post
Share on other sites
Noods,

In your example you are using an actual object instance to access the member so you would use the . operator.

cheddar.color


Now if cheddar was a pointer to a Cheese object like this:

Cheese* cheddar = new Cheese;

then you would use the -> operator.

cheddar->color

which is as Raloth pointed out equivalent to

(*cheddar).color

[edited by - SpaceRogue on August 16, 2003 2:13:26 PM]

Share this post


Link to post
Share on other sites
You would use the "->" operator if the aforementioned class was a pointer.

Using your Cheese example:

Cheese myCheese;

myCheese.color = "red";

That''s what you would do normally.

Cheese* myCheese;

myCheese = new Cheese;
myCheese->color = "red";

Note the difference. Hope that helped!

Share this post


Link to post
Share on other sites
Aha! Its amazing how a person can explain something in 5 seconds where it takes a book 3 pages

Share this post


Link to post
Share on other sites

  • Advertisement