![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Can you program without pointers?
Hey people.
Ive read so many tutorials about pointers, but i simply cant get them. I understand their syntax and everything, but i cant understand what their really for. To me, their just simple intengers. So is it possible to write a really really large program without using pointers or classes? |
|
|
|
|
|
#2 | ||
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
||
|
|
|
|
|
#3 | |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
Quote:
Well, No.
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
|
#4 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#5 | |
|
Newbie
Join Date: Apr 2006
Location: Israel
Posts: 4
Rep Power: 0
![]() |
Quote:
look dude, it's possible to write large program without pointers or classes , but it will be undebugable.. and probebly a crappy piece of code no one else understand .. to understand pointers you need to use them, for example , try to implement a linked list.. or even send array as parameter to another function.. after i used VB for very long time, it took my a while to understand why you need pointers, you'll get it with time.. good luck m8 |
|
|
|
|
|
|
#6 | ||
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,193
Rep Power: 5
![]() |
Quote:
As to what pointers are really for, one of their main purposes is to increase efficiency. Rather than pass a large block of memory, you can pass a pointer to the start of the block. On most modern systems, a pointer is 32 bits, or four bytes, while a block of memory might be quite a bit larger, like several megabytes. It's much faster to copy four bytes than it is to copy a few million. Pointers are also used to allow you to create dynamic data structures. In other words, you can determine the size of arrays and other such things at run time, rather than compile time. This makes your program more efficient (since it doesn't need to allocate 10000 elements when it only needs 100), and more capable (since it doesn't choke when it needs more than a hard-coded 100 elements). You will find pointers used extensively in most operating system APIs, for a variety of reasons. Without learning how to use them, you really won't be able to write anything but the most trivial programs. Even languages that try to do away with pointers usually have them. If you've ever heard of an 'object reference' in Java, it's essentially a pointer, and if you ask me, trying to hide them from the programmer creates more problems than it solves. Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
||
|
|
|
|
|
#7 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#8 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
Odds are you've been using pointers all along and didn't even realize it. Like arrays for instance. All those really are is pointers.
And if you ever want to work with advanced data structures, or even 2D arrays really, you'll need to know them. If you want to see an application of them, trying making a linked list, or binary search tree. |
|
|
|
|
|
#9 | ||
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#10 |
|
Hobbyist Programmer
|
var x = My House
var *x = 555 main st. var **x = Phone Book Data is stored in memory (RAM). Each byte has an address associated with it. Something like 0x010000. I cant remember how long they are exactly but you get the idea. x is the data itself. *x is the address. **x is the address of where the pointer is located. * could be read as "the address of". I too get confused by pointers and sometimes still do. You'll get better with practice. Also, I agree with Grumpy. Java and many other languages where developers get big bucks, never use pointers. It just so happens that the things Java can do without pointers, C will make use of them in that situation. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|