Sign in to follow this  

What's the difference?

Recommended Posts

I just saw somebodies signature that reminded me to ask this question. What is the difference between "->" and "."? I'm pretty sure -> has to do with pointers but Why use it if . can do the same thing, or at least that's what I think. for example: You can use these both and they would work the same.. if(cat.brown == TRUE) and if(cat->brown == TRUE) So, in what case would -> be necessary to use?

Share this post

Link to post
Share on other sites
Original post by Tera_Dragon
You are correct, the -> operator is for use with pointers. The reason (or the only one I can think of) is to be able to easily see if a variable is a pointer or not.

I think Alpha_ProgDes showed what the benefit is...

// quicker to type
// slow to type
// not to mention confusion is avoided...
* ); // not the same as (*ptr).foo()

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this