Stuck again.

This is a discussion on Stuck again. within the C++ Programming forums, part of the General Programming Boards category; Not sure if I am on the right track with the code below. This is what I need, I know ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    40

    Stuck again.

    Not sure if I am on the right track with the code below. This is what I need, I know I am missing stuff, just not sure how to put it in here!
    Write a recursive implementation, the operation should have as parameters the array, an item, and the size of the array and return the position of the item. Since the array is being
    passed as a parameter, this will be a private function in the class.
    Thanks for everybodies help!!!! You have all been great!

    Code:
     
    list::() :size = (0) //would this be the array? where does the //private function go?
    
    
    void List::insert (int index, ListItemType newItem, 
                              bool& success) 
    { 
        success = bool( (index >= 1) && 
                                 (index <= size +1) && 
                                 (size < MAX_LIST) ); 
        if (success) 
        { 
          items[translate(index)]=newitem; 
          ++size; 
           insert(index+1,newitem,success); 
        } 
    }

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    >>the operation should have as parameters the array, an item, and the size of the array and return the position of the item. Since the array is being passed as a parameter, this will be a private function in the class.

    Code:
    template <typename T> 
    class List
    {
       private:
    	 T * array;//memory for array will be dynamic
    	 int insert(T * array, T item, int size);
    ....
    you mean something like that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 10-23-2006, 07:22 PM
  2. string array stuck:(
    By mass in forum C Programming
    Replies: 18
    Last Post: 05-22-2006, 04:44 PM
  3. Program stuck in infinite loop-->PLEASE HELP
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 03-26-2005, 11:40 AM
  4. Stuck on random generating
    By Vegtro in forum C++ Programming
    Replies: 3
    Last Post: 10-01-2003, 07:37 PM
  5. stuck ky
    By JaWiB in forum Tech Board
    Replies: 2
    Last Post: 06-15-2003, 08:28 PM

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