Advertisement Jump to content
Sign in to follow this  
Grantyt3

What Does '*' Mean?

This topic is 4642 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

When declaring certain variables, it seems that you have to add a * at the end of the type, for example : SDL_Surface* mainScreen; What does that asterisk do?

Share this post


Link to post
Share on other sites
Advertisement
it means POINTER

so this variable can store an address of another variable (or structure in this case) of the same type.

read more here: http://www.cplusplus.com/doc/tutorial/pointers.html

Share this post


Link to post
Share on other sites
* have a couple of meanings depending on when and how it is used.

int * ptr_mine; means you are creating a pointer to an int.

int c = *ptr_mine, mean you are depreicating the pointer, getting the value that the pointer points to and not the value of the pointer itself.

In your case SDL_Surface* mainScreen; is a pointer to the type SDL_Surface, remember a pointer is just a memory address that "point" the variable you are using, it is NOT the variable

theTroll

Share this post


Link to post
Share on other sites
Quote:
Original post by TheTroll
int c = *ptr_mine, mean you are depreicating the pointer, getting the value that the pointer points to and not the value of the pointer itself.

You mean dereferencing, I think. To "deprecate" is the gradual phasing-out of obsolete functionality.

Share this post


Link to post
Share on other sites
Yeah that is what I ment. It has been many years since I took a class in C, guess my terms are a little messed up.

theTroll

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!