| |

VerySource

 Forgot password?
 Register
Search
View: 810|Reply: 7

Delete question !!

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-8 15:30:02
| Show all posts |Read mode
void INput :: deleteemployee () {
string name;
list <CEmployee *> :: iterator it = pEmplist.begin ();
list <CEmployee *> :: iterator it_end = pEmplist.end ();
cout << "Please enter the name of the employee you want to delete:"; cin >> name; // output the name of the person to delete
while (it! = it_end) // Sequence search for the person to delete
{if ((** it) .EmpolyeeName () == name)
{pEmplist.erase (it);
// cout << "The employee information you want to delete has been deleted" << endl;
break;}
it ++;
}
if (it == it_end) // Cannot find the user to delete
cout << "sorry, there is no one that you want!" << endl;
}
I'm depressed, it still works. It doesn't work now, it seems to be pEmplist.erase (it);
list <CEmployee *> I have user information here
The masters give pointers!
Reply

Use magic Report

0

Threads

55

Posts

44.00

Credits

Newbie

Rank: 1

Credits
44.00

 Invalid IP Address

Post time: 2020-5-29 00:00:02
| Show all posts
Just use list :: remove
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-29 13:45:01
| Show all posts
How to use it! Brother, I won't. I only know erase other things ... I hope the master can help !!
Reply

Use magic Report

0

Threads

49

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-5-29 19:00:01
| Show all posts
if (it == it_end) // Can't find the user to delete
------------------------------------------------
I think there is something wrong with this sentence, if the deleted one is the last one
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-30 07:30:01
| Show all posts
Brother, change to pEmplist.remove (* it); break; still pop up a window at runtime What is the ASSERT value class
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-30 10:00:01
| Show all posts
When I tried, instead of deleting the last one, an error popped up in a window ...
Reply

Use magic Report

0

Threads

49

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-5-30 10:30:01
| Show all posts
c.remove (val) removes all elements with value val in c (list)
Reply

Use magic Report

0

Threads

37

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-5-30 20:15:01
| Show all posts
void INput :: deleteemployee () {
string name;
cout << "Please enter the name of the employee you want to delete:"; cin >> name;

for (list <CEmployee *> :: iterator it = pEmplist.begin (); it! = pEmplist.end (); it ++)
if ((** it) .EmpolyeeName () == name)
break;

if (it == it_end)
cout << "sorry, there is no one that you want!" << endl;
else
pEmplist.erase (it);

}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list