Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 pointers?
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
PaddyLong




PostPosted: Wed Jul 09, 2003 7:32 pm   Post subject: (No subject)

lol we oce had a geography teacher that said the entire ocean froze over
Sponsor
Sponsor
Sponsor
sponsor
UBC_Wiskatos




PostPosted: Wed Jul 09, 2003 8:27 pm   Post subject: (No subject)

[quote="Homer_simpson"]
tony wrote:
me too, OOP pwnz Laughing
quote]
from what i know...pointers have nothing to do witg OOP...right now we're doing oop programming in c++ and i haven't used a single pointer...well mayb 1 or 2 =p


Well theoretical OOD and well-done OOD are two different things. Smile
AsianSensation




PostPosted: Wed Jul 09, 2003 8:50 pm   Post subject: (No subject)

whoa, never knew pointers could do this much...

oh well, then it's just another reason to start learning them and using them...
Homer_simpson




PostPosted: Wed Jul 09, 2003 10:43 pm   Post subject: (No subject)

UBC_Wiskatos wrote:

Well theoretical OOD and well-done OOD are two different things. Smile

what's OOD??!! Confused
Catalyst




PostPosted: Wed Jul 09, 2003 10:52 pm   Post subject: (No subject)

object oriented design (unless thats a typo)
Homer_simpson




PostPosted: Wed Jul 09, 2003 10:56 pm   Post subject: (No subject)

lol... object oriented designing(even that is a word) has nothing to do with what i'm doing i'm pretty sure that i'm doing OOp
Catalyst




PostPosted: Wed Jul 09, 2003 11:21 pm   Post subject: (No subject)

ood is planning out how all ur classes interact and are used
Mazer




PostPosted: Thu Jul 10, 2003 9:21 am   Post subject: (No subject)

speaking of pointers.... Wink

here's what i understand about them (which isn't much). unless i'm mistaken, pointers are supposed to make better use of your computer's memory. instead of declaring a variable and thus having your computer set aside a certain amount of memory for that variable, declaring a pointer set's aside a certain amount of memory so you can store the address to another memory location that stores information for an object. this way, once you're done with the object you can set it's pointer to NULL and it's like it never existed so the memory it was taking up is now free.

or something...
chances are that i am wrong because i don't really know what i'm talking about. please, someone correct me if that is so.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Jul 10, 2003 9:48 am   Post subject: (No subject)

no finally ur allocating memory of the object whether u like it or not.
and after ur done with the object u have to free the allocated memory!

as i said just think of pointers as a feature of c++
Mazer




PostPosted: Thu Jul 10, 2003 12:31 pm   Post subject: (No subject)

rizzix wrote:
and after ur done with the object u have to free the allocated memory!


isn't that what your doing by setting the pointer to NULL?
UBC_Wiskatos




PostPosted: Thu Jul 10, 2003 1:31 pm   Post subject: (No subject)

Mazer wrote:
rizzix wrote:
and after ur done with the object u have to free the allocated memory!


isn't that what your doing by setting the pointer to NULL?


No, NULL is a C macro that sets the pointer to memory address 0. The memory is still in use, you just can't access it anymore. This creates a memory leak, because when more memory is allocated, that object hasn't been deleted and no new memory can be created there until the computer is restarted.

A pointer allows you to work directly with the object in memory, it is as simple as that. This has speed benefits and other things. However, keep in mind that a pointer is just a gateway to your memory, when you delete it, the memory is still there.

I've used this analogy before. Say you have a neighbourhood lot with 10 houses. In one of the houses, there is a broken pipe, and you have to call the plumber.

Now, the plumber can do two things. He can go directly to the house and fix the pipe (faster), or he can make his own model of that same house, figure out how to fix it, then go to the house and fix the house (slow). The house is the object, the plumber is the agent, and the address is the pointer. By using a pointer, you just go straight to the house. By not using a pointer, the compiler creates a copy of the object in a function (that is, ByVal).
Mazer




PostPosted: Thu Jul 10, 2003 1:39 pm   Post subject: (No subject)

ok... so how would you free the memory being used by the object you created?
rizzix




PostPosted: Thu Jul 10, 2003 1:54 pm   Post subject: (No subject)

use the delete operator =)
rizzix




PostPosted: Thu Jul 10, 2003 1:59 pm   Post subject: (No subject)

AsianSensation wrote:
whoa, never knew pointers could do this much...

oh well, then it's just another reason to start learning them and using them...


no one will consider u a C/C++ programmer if u don't know how to use poitners.. cuz a lot of the libraries available out there use pointers/references extensively... without that knowledge ur lost!
Homer_simpson




PostPosted: Thu Jul 10, 2003 2:39 pm   Post subject: (No subject)

here's a tutorials on pointers basic : http://www.cplusplus.com/doc/tutorial/tut3-3.html
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 30 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: