Thread: Need way to end

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

    Need way to end

    I need a way for this recursive to end when the item is not in the list. Can you help? Thanks!!

    Code:
     
     template <typename T> 
    class List
    {
       private:
    	 T * array;//memory for array will be dynamic
    	 int insert(T * array, T item, int size);
    
    
     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
    Nov 2001
    Posts
    1,348
    The insert function does not match in the interface and implementation.

    One solution is to do the check before the if statement.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    40
    Ok, not sure how to do that. Would it be another if statement?

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    40
    How about, search the array and if the value is found return the location of the value, that is the value in position 1 or 6 or ?. How do I do that?
    Thanks!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Modify to make Doubly Linked List
    By Dampecram in forum C Programming
    Replies: 10
    Last Post: 11-03-2008, 07:25 PM
  3. singly linked to doubly linked
    By jsbeckton in forum C Programming
    Replies: 10
    Last Post: 11-06-2005, 07:47 PM
  4. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  5. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 02:40 PM