PHO - Pokémon Hackers Online
Go Back   PHO - Pokémon Hackers Online > Homebrew & Coding > Coding Discussion

Coding Discussion Discuss programming and coding and get help here.

Reply
 
Thread Tools Display Modes
Old 19th August 2014, 12:25 AM   #1
Xansus
Gen II Aficionado
 
Join Date: Oct 2013
Age: 23
Posts: 19
Xansus
Default C++ Pointers

Hi could someone explain how pointers work? I cant use it because I cant figure out how they work. Note that Im only self studying c++ just so you guys know.. And I just started. I hope you guys can help me out.
Xansus is offline   Reply With Quote
Sponsored Links
Old 21st August 2014, 01:46 AM   #2
Jambo51
Glory To Arstotzka
Ex-Staff
 
Jambo51's Avatar
 
Join Date: May 2012
Location: Scotland
Posts: 92
Jambo51
Default

Pointers are great. As opposed to a data type, think of it as something that points to data, hence the name. All pointers (regardless of the base type) are stored as 32 (or 64 on modern computers) bit values which simply represent a memory location at which relevant data can be found.

By casting pointers, you can have them use the correct programme logic for the data at the pointed to location.

Your question is extremely generic though, so I'd like to ask you one back. What exactly do you want to know about pointers?
__________________
I have nothing interesting to add
Jambo51 is offline   Reply With Quote
Old 24th August 2014, 07:10 AM   #3
Xansus
Gen II Aficionado
 
Join Date: Oct 2013
Age: 23
Posts: 19
Xansus
Default

Yeah that seems a bit generic.. Im trying to learn pointers so that I could use it on my upcoming projects and Id like to know how I can make use them.. Id like to know the purpose of pointers.. They all say that pointers are great but I dont know their exact purpose when programming since Ive finished projects and not use them..
Xansus is offline   Reply With Quote
Old 7th September 2014, 04:11 PM   #4
cosarara
Programming and asdf
 
cosarara's Avatar
 
Join Date: Sep 2014
Location: Near Barcelona
Age: 20
Posts: 12
cosarara
Default

I think you should read a book which explains the topic, but anyway, an example use case:
Say you want your program to create some instances of a class, but the number will depend on the input so you can't just declare them beforehand. You will have to use dynamic memory, using the new keyword.
When you do that, you'll get a pointer to the object in that dynamic memory.

Pointers are used directly a lot more in C than in C++, since pass-by-reference hides one of the most common use cases, but you should understand them anyway (and even more so if you are into ROM hacking!).
cosarara is offline   Reply With Quote
Reply

Tags
pointers

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:53 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc. User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Pokémon characters and images belong to Pokémon USA, Inc. and Nintendo.
Pokémon Hackers Online (PHO) is in no way affiliated with or endorsed by Nintendo LLC, Creatures, GAMEFREAK inc,
The Pokémon Company, Pokémon USA, Inc., The Pokémon Company International, or Wizards of the Coast.
All forum/site content (unless noted otherwise) and site designs are © 2006-2013 Pokémon Hackers Online (PHO).
Green Charizard Christos TreeckoLv100

"Black 2" by ARTPOP. Kyurem artwork by XOUS.

no new posts