Thread: struc link List

  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,897
    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,897
    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, 10: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, 10:33 PM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM