Linked list with abstract base class?

This is a discussion on Linked list with abstract base class? within the C++ Programming forums, part of the General Programming Boards category; Hi, my name is Mario, 35 years old. There introductions are out of the way. I am here because I ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    2

    Linked list with abstract base class?

    Hi, my name is Mario, 35 years old.

    There introductions are out of the way. I am here because I need a little help. It is for a class assignment so don't help me more than you feel comfortable with.

    The assignment is to create a program that will track Employees and Clients. Both Employees and Clients have a First and Last name. In addition Employees have an ID number (9 digits), classified as either support or secure, clearance level, and pager number. The Clients have an ID (5 alphanumeric). It is a simple program as all I need to do is enter info, retrieve a single persons info, and print the whole list.

    What I want to do is have an Abstract Base Class (Person) for the First and last name. Client and Employee classes will be descendents to Person. Support and Secure classes will be descendents to Employee. I want to set up the info as a linked list.

    the question I have is How do I set up the Struct for the list? In the base class? Descendents? Both?

    Thanks for any light you can shed.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What are the rules? Can you use STL classes?

    What do YOU think is the best solution?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2
    1) Create abstract base class for person that encompasses common data of employees and clients then create classes for employees and clients as descendents.

    2) Create classes for secure and support employees as descendents of Employee.

    3) Finally, create structures to store and retrieve employees and clients, and a program that allows the user to interact with these structures.


    Pretty liberal rules. I thought I would create a Structure for a list and go that route. I am just not sure where the list should be defined. Right now I am thinking the best route would be to make a new class for the list and after all the information is collected (via person, employee, client, etc classes) pass it to the list class to create the appropriate node all at once.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So you can't use "std::list" or "std::vector"?

    I agree, splitting the linked list from the rest of the data is a good idea - it reduces the complexity of each class.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,765
    Quote Originally Posted by mariolov View Post
    1) Create abstract base class for person that encompasses common data of employees and clients then create classes for employees and clients as descendents.
    Usually, in "C++ speak," we would say that employees and clients are derived from person

    2) Create classes for secure and support employees as descendents of Employee.
    Again, derived from

    Also, employees and clients inherits from Person.
    Just heads up a little on your programming language skillls
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I'm not so sure this project needs that many levels of derivation. Keep it simple.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 07:53 PM
  2. template and friend class
    By black_spot1984 in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2008, 05:50 PM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

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