struc link List

This is a discussion on struc link List within the C++ Programming forums, part of the General Programming Boards category; I want to create a link list that can stores more than one data type. For example, I have a ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Question struc link List

    I want to create a link list that can stores more than one data type. For example, I have a struct Customer which has char name[15] , char gender and int age. Can I create a link list that store a data type Customer? If yes please show me an example.
    Thank You!!!!!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Linked lists use either structures or classes as their nodes, so the answer to your question is a definite yes.
    Code:
    /*struct version*/
    struct node{
        char name[15];
        char gender;
        int  age;
    
        node * next;
    };
    
    /*class version*/
    class node{
        private:
            char name[15];
            char gender;
            int age;
        public;
            void setName(char * s);
            void setGender(char c);
            void setAge(int i);
            char * getName();
            char   getGender();
            int    getAge();
    
            node * next;
    };
    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Thumbs up Thanks

    Thank you so much Prelude!!
    This will help me start my problem. If I have more question can I ask you?
    Lien

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Of course, if I can help then I will.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List Insert prob
    By Bebs in forum C Programming
    Replies: 8
    Last Post: 12-03-2008, 09:28 PM
  2. reading data from a file - link list
    By peter_hii in forum C++ Programming
    Replies: 7
    Last Post: 10-25-2006, 09:11 AM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 09:16 AM
  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