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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    What does this mean
    cast null-pointer to the type Pointer to Class LinkableClass
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    21,648
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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