0
A Get function’s inverse
For my code, I have two functions, “get_no_of_students”, and “add_student”. How would I go about creating a “drop_student” function that removes a student that I have added? https://code.sololearn.com/cCIDeBB1cZCE/#cpp This is the code for my cpp file, i will link the header as well edit: https://code.sololearn.com/c6g42qUYhbCA/#cpp
4 odpowiedzi
+ 4
That would depend somewhat on how you implemented the other functions (or class with methods).
Care to share your code? You can upload it in Code Playground and link it here.
+ 1
https://code.sololearn.com/cCIDeBB1cZCE/#cpp
This is the code for my cpp file, i will link the header as well
edit: https://code.sololearn.com/c6g42qUYhbCA/#cpp
+ 1
You would need to iteratorate through the array of student names, checking to find a matching name.
If found you can remove It be moving all the following names down one slot in your array. If order doesn't matter, then you can just assign the last name to the this slot.
Then decrease the number of students by one.
0
thanks so much 👍🏽 Jared Bird