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 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
AsianSensation




PostPosted: Tue Jul 08, 2003 9:33 pm   Post subject: pointers?

I have a question: What's the reason for using pointers? I am learning this stuff right now, but I fail to find a reason for the use of pointers...

is it for speed, or organization? Or am I simply not getting some fundamental ideas or stuff behind C++?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jul 08, 2003 10:39 pm   Post subject: (No subject)

pointers to the object? as in

something -> function ?

man, thats what OOP is all about, to create objects and use them. Objects are objects, for example, a brick. It is an universal set of functions and variables that is the same in every of your walls (programs), but when you're building the wall (programming using OOP) you have to point to what kind of brink you want to be using.

Now a real programming example. You know how modules work, right? The Draw.Dot where Draw is the name of the module and Dot is name of the function? Its quite similar to the object, but with OOP, you can create a variable and point it to the object. You could create an array of objects. And have something like Drawing(2)->Draw.Dot

I hope this clears OOP basics up.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
UBC_Wiskatos




PostPosted: Tue Jul 08, 2003 11:18 pm   Post subject: Re: pointers?

AsianSensation wrote:
I have a question: What's the reason for using pointers? I am learning this stuff right now, but I fail to find a reason for the use of pointers...

is it for speed, or organization? Or am I simply not getting some fundamental ideas or stuff behind C++?


A pointer is crucial for effective organization of code, for speed, for various algorithms, for data storage, and for dynamic stuff. Pointers play very important parts in APIs, and DLLs designed to be reusable, as well as COM objects and whatnot. It's hard to see why pointers are so important without beginning to use them. For example, my graphics engine is at its core, based on a large amount of pointers, which make it fast, reusable, scalable, robust, and whatnot. There's many types of pointers which are used for different things... Function pointers, void pointers, pointers used in callback functions, etc.
SilverSprite




PostPosted: Wed Jul 09, 2003 1:18 am   Post subject: (No subject)

They wouldn't invent them if they weren't useful.. so it's probably you not understand what OOP is or inexperience.
Tony




PostPosted: Wed Jul 09, 2003 2:34 am   Post subject: (No subject)

SilverSprite wrote:
They wouldn't invent them if they weren't useful..


well they did publish turing Rolling Eyes

Laughing seriosly though there are some weird things in programming languages... like goto... everybody hates them, but it still works Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SilverSprite




PostPosted: Wed Jul 09, 2003 2:51 am   Post subject: (No subject)

well turing if for ppl who are just learning a new language.. and for those who find it hard to understand programming.. haha goto that thing is weird..
rizzix




PostPosted: Wed Jul 09, 2003 2:55 am   Post subject: (No subject)

people hate goto cuz it lead to VERY BAD CODE. practically completely cryptic.

btw what's the point of point-ers? lol...
hmm just some C carry over to c++ thingie.
they could've just stuck to references.. but then u wouldn't have pointer arithmetic..

although u don't need that pointer arithmetic.. some languages just got rid of pointers.. since it usually leads to, lets say difficult to debug code... for them references were good enough.

this dosen't mean pointers are bad.. just think of them as a feature of c/c++
SilverSprite




PostPosted: Wed Jul 09, 2003 2:59 am   Post subject: (No subject)

i love pointers to functions:D
Tony




PostPosted: Wed Jul 09, 2003 3:01 am   Post subject: (No subject)

me too, OOP pwnz Laughing

the best part (other then the usual reusable rebust programming speach) is that instead of writing a complex function that figures out what objecest it does calculations for, you point to a function from the object Very Happy Its great.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rizzix




PostPosted: Wed Jul 09, 2003 3:13 am   Post subject: (No subject)

pointers to functions isn't part of oop though Wink it is still procedural,, something c++ inherited from c
pointers to Objects ,,, oh yes, now thats OOP Smile
and there is an correct OOP equivalent of Pointers to Functions as well.
UBC_Wiskatos




PostPosted: Wed Jul 09, 2003 11:46 am   Post subject: (No subject)

rizzix wrote:
people hate goto cuz it lead to VERY BAD CODE. practically completely cryptic.

btw what's the point of point-ers? lol...
hmm just some C carry over to c++ thingie.
they could've just stuck to references.. but then u wouldn't have pointer arithmetic..

although u don't need that pointer arithmetic.. some languages just got rid of pointers.. since it usually leads to, lets say difficult to debug code... for them references were good enough.

this dosen't mean pointers are bad.. just think of them as a feature of c/c++


Well unless you program in assembly, then goto or its equivalent are the only thing you have. Wink
Homer_simpson




PostPosted: Wed Jul 09, 2003 1:34 pm   Post subject: (No subject)

[quote="tony"]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
Tony




PostPosted: Wed Jul 09, 2003 6:37 pm   Post subject: (No subject)

i dont care, OOP still pwnz Laughing

besides, cant entirely trust what they teach you in school.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rizzix




PostPosted: Wed Jul 09, 2003 6:49 pm   Post subject: (No subject)

I Agree Laughing
SilverSprite




PostPosted: Wed Jul 09, 2003 6:54 pm   Post subject: (No subject)

Yeah I'll have to agree too..
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 1 of 2  [ 30 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: