hetrogenous linked list

This is a discussion on hetrogenous linked list within the C++ Programming forums, part of the General Programming Boards category; I have found from an ebook that we can maintain links between hetrogenous elements by void pointer.But then how we ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    113

    hetrogenous linked list

    I have found from an ebook that we can maintain links between hetrogenous elements by void pointer.But then how we will be able to derefrence it since, derefrencing void pointer is illegal and also we do not know the type of node at prior to runtime.

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    Did the book said you can?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581
    There are a few ways to build heterogeneous containers. It involves a few tricks obviously. As you realized, it can't be done in a simple way.

    http://www.acims.arizona.edu/EDUCATION/HCCL/

    However, if you are trying to hold elements in a linked list pointing to a base hierarchy, you can effectively hold any of the derived types without the need to resort to pointers to void.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

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, 11:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  3. Adding directory/file names to a linked list
    By thoseion in forum C Programming
    Replies: 13
    Last Post: 12-08-2006, 01:13 PM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

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