Linked List

This is a discussion on Linked List within the C++ Programming forums, part of the General Programming Boards category; Code from a book: Code: class LinkableClass { public: LinkableClass* pNext; //other members } LinkableClass* pHead = (LinkableClass*)0; What does ...

  1. #1
    Super unModrator
    Join Date
    Dec 2007
    Posts
    321

    Question Linked List

    Code from a book:

    Code:
    class LinkableClass
    {
          public:
                    LinkableClass* pNext;
                    //other members
    }
    
    
    LinkableClass* pHead = (LinkableClass*)0;
    What does this mean
    Code:
      (LinkableClass*)0
    ?

  2. #2
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,754
    What does this mean
    cast null-pointer to the type Pointer to Class LinkableClass
    To be or not to be == true

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Its a cast, albeit unnecessary. It just defining pHead as 0 and telling the compiler to consider 0 an object of the LinkableClass type.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,819
    The cast is unnecessary though.

    EDIT:
    telling the compiler to consider 0 an object of the LinkableClass type
    Not really. More like it means that pHead is a null pointer.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Super unModrator
    Join Date
    Dec 2007
    Posts
    321
    Thanks all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 08:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21