Thread: how to delete from list

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    1

    Question how to delete from list

    Code:
    class Person{  
          public:
                 string name;
                 string address;
                 string phone;
          
          public:
                 friend ostream& operator<< (ostream& out,const Person& person){
                        out.setf(ios::left);
                        out.width(sizeof(person.name)+6);
                        out<<person.name;
                        out.width(sizeof(person.address)+6);
                        out<<person.address;
                        out.width(sizeof(person.phone));
                        out<<person.phone<<endl;
                        return out;
                        } 
                  friend istream& operator>> (istream& in, Person& person){
                         in.width(sizeof(person.name)+6);
    	                 in>>person.name;
    	                 in.width(sizeof(person.address)+6);
    	                 in>>person.address;
    	                 in.width(sizeof(person.phone)+6);
    	                 in>>person.phone;
                         return in; 
                         }
    };      
    
    list<Person> L;                                          
    list<Person>::iterator i;  
    
    bool find (Person pers, const list<Person> &L){
         
         for(list<Person>::const_iterator i = L.begin(); i != L.end(); ++i){
             if(((Person)*i).name == pers.name ){
                return true;
             }
         }   
    }
    
    void deleteR(){
         
                       Person person;
                              cout<<"\nEnter name: ";
                              cin>>person.name;
                              
                              if(find(person,L)){
                                        remove(person);  dont work...
                                          
                              }
                            
    }
    how i can.. delete from list..??plz help
    Last edited by Aljena; 12-13-2006 at 07:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. circular doubly linked list help
    By gunnerz in forum C++ Programming
    Replies: 5
    Last Post: 04-28-2007, 08:38 PM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  4. Anyone good with linked list.....I am not....
    By chadsxe in forum C++ Programming
    Replies: 11
    Last Post: 11-10-2005, 02:48 PM