Posted: 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
Tony
Posted: 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 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
Posted: 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
Posted: 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
seriosly though there are some weird things in programming languages... like goto... everybody hates them, but it still works
Posted: 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
Posted: 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
Posted: Wed Jul 09, 2003 2:59 am Post subject: (No subject)
i love pointers to functions:D
Sponsor Sponsor
Tony
Posted: Wed Jul 09, 2003 3:01 am Post subject: (No subject)
me too, OOP pwnz
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 Its great.
Posted: Wed Jul 09, 2003 3:13 am Post subject: (No subject)
pointers to functions isn't part of oop though it is still procedural,, something c++ inherited from c
pointers to Objects ,,, oh yes, now thats OOP
and there is an correct OOP equivalent of Pointers to Functions as well.
UBC_Wiskatos
Posted: 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.
Homer_simpson
Posted: Wed Jul 09, 2003 1:34 pm Post subject: (No subject)
[quote="tony"]me too, OOP pwnz
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
Posted: Wed Jul 09, 2003 6:37 pm Post subject: (No subject)
i dont care, OOP still pwnz
besides, cant entirely trust what they teach you in school.