Go to Post if your robot weighs 1-1/2 tons, you have bigger problems then the legality of that jack... - ekapalka [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 21-03-2012, 20:17
ctccromer's Avatar
ctccromer ctccromer is offline
Animus
AKA: Tucker Campbell
FRC #3753 (Bulah Bots)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Baton Rouge, Louisiana
Posts: 190
ctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to all
Re: C++ help: Understanding pointers?

Okay so I know that pointers simply point to another variable/memory location and can both change locations or change the value of the pointed-to's variable. I know pointers are used to borrow memory when you need it.
I DON'T know when/why you need extra memory and when you need to/dont need to use pointers.
I DON'T know how new/delete work all the way. here's an example of what I'm confused on for them:

int Number;
int *p_Number = new int;
int p_Number = Number;

So this creates an integer (Number), creates a pointer (p_Number) and gets enough memory for an integer ("new int"), then makes the pointer point to the original integer.
1. Is this how you would go about making room for a variable, making that variable and setting it to the pointer?
2. Is there a certain order or does it not matter?
3. Why do I need to get room (via "new") if the program will run fine without having to grab memory for it? And doesn't it defeat the purpose if I create an integer before getting room for one?

P.S. Why are there references? They're just half-pointers.. Why not use pointers when you'd use references and have one less thing to remember?
__________________
Team 3753 BulahBots
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:15.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi