Thread: Question?

  1. #1
    Registered User
    Join Date
    Aug 2001


    I am transfering from a jounior college to a four year college. This semester I am taking science classes (no programming classes). I have talked to other students in the computer science program and most of them are clueless about pointers. I have taken up to the first data structures at the jounior college I was attending. Is it possible to do a linked list or a Queue without pointers? The students at the four year college I have started going to are focused on pass by reference.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    No there is not and why should there? Pointers aren't THAT difficult...
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    I honestly do not see the problem everyone has with pointers. A pointer is simply a variable that holds an address. Everyone gets so caught up in implementation that they forget that basic fact and become confused.

    My best code is written with the delete key.

  4. #4
    Join Date
    Aug 2001
    Groningen (NL)
    I think that many people get confused because they think too abstract. As Prelude says, a pointer is just a variable. The only difference with 'usual' variables is that it contains an address. Perhaps programming books should tell something about how memory in a computer is organised, like K&R does. Then people would better understand what a pointer is.

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    I know that when I was learning about them, the main problem wasn't understanding what they are (since every tut under the sun says "it's a variable that contains an address"), but how to use them. When to dereference them, and the like. Also, I think scop should be taught before this - when I was beginning to learn, I couldn't figure out why you'd ever want to use them, because I didn't totally get that variables declared in a function couldn't be altered in another one without the use of them.

  6. #6
    Registered User
    Join Date
    Oct 2001
    You can do a Queue without pointers. But a linked list would be difficult.

  7. #7
    Registered User
    Join Date
    Dec 2001
    For a linked list without pointers, you'll have to create 2 arrays:

    int data[100],next[100];

    data[] will contain the actual data values, and corresponding next[] will contain the next element after the current one.


    index data next
    0 20 2
    1 25 -1 < --- can use this to indicate end of list
    2 56 4
    3 99 1
    4 23 3

    So the linked list goes like this: 0 -- 2 -- 4 -- 3 -- 1 -- END

    There are many modifications/additions possible to this of course.

    Hope this helps

  8. #8
    Registered User
    Join Date
    Dec 2001
    Just adding...

    You can also have a prev[] array to hold index of previous element in case you want a doubly linked list.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM