Stuck on Lists

This is a discussion on Stuck on Lists within the C++ Programming forums, part of the General Programming Boards category; Hey, I am having some problems with this program that was given to me. I was given the main program ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    81

    Stuck on Lists

    Hey, I am having some problems with this program that was given to me. I was given the main program and had to create a list class to use the fxns called in the main program. Well, I am having some problems with the functions themselves (what to put in them). Oh, the data manipulated is in an array without using pointers. I have included the main program

    here is the code for the header:

    Code:
    #include <iostream>
    using namespace std;
    
    class List
    {
    public:
    typedef int value_type;
    static const value_type CAP=30;
    value_type mylist[CAP];
    List();
    List(List& x);
    //void destroy();
    //void assign();
    void remove();  //destroy operation
    void first(); //first operation
    void next(); //next operation
    void prev(); //previous operation
    void Makecurrent(); //makecurrent operation
    value_type examine(); //examine operation
    void replace(value_type v); //replace operation
    value_type insertafter(value_type v); //insert after operation
    value_type insertbefore(value_type v); //insert before operation
    value_type size(); //Count operation
    friend ostream & operator<<(ostream& out, List x)
    {
    return out << x;
    }
    
    private:
    int pos;
    int used;
    };
    List::List()
    {
    pos=0;
    used=0;
    }
    List::List(List& x)
    {
    pos=x.pos;
    used=x.used;
    }
    void List::remove()
    {
    
    }
    void List::first()
    {
    pos=mylist[0];
    
    }
    void List::next()
    {
    if(pos<used)
    pos++;
    }
    void List::prev()
    {
    if(pos>used)
    {pos--;}
    pos--;
    }
    List::Makecurrent()
    {
    
    }
    value_type List::examine()
    {
    return pos;
    
    }
    void List::replace(value_type v)
    {
    
    
    }
    value_type List::insertafter(value_type v)
    {
    	
    if(used>CAP)
    	return 0;
    for(int i=used;i>pos;i--)
    	mylist[i+1]=mylist[i];
    	pos++;
    	mylist[pos+1]=v;
    	used++;
    	return 1;
    }
    value_type List::insertbefore(value_type v)
    {
    if(used==0)
    	return 0;
    //for(int i=)
    }
    value_type List::size()
    {
    return used;
    
    }
    thanks
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help creating lists of pointers
    By The_Kingpin in forum C Programming
    Replies: 2
    Last Post: 12-11-2004, 07:10 PM
  2. Question about Linked lists of lists
    By hear_no_evil in forum C Programming
    Replies: 2
    Last Post: 11-08-2004, 01:49 AM
  3. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  4. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 10:32 PM
  5. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 08:57 PM

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