I'm learning container list. And I want to write function to replace (element on index), insert (element on index), and I want to know how to delete them. I'm learning this about two day I watched videos and read articles but I just don't know how to write this code. I know how list work's with pointers.
This is how I imagined (it is just a start)
void replace(list<Contact> &listOf, int index, const Contact &information) { for(list<int>::iterator it = listOf.begin(); it != listOf.end(); it++){ } } I don't know if the for loop is writen right, but I imagined that it go through list and if it finds index which wants to replace it will juse overwrite.
I think function insert has the same parameters.
And this is how I imagined for delete it but i'm not quit sure how to implement.
Contact delete(list<Contact> &listOf, int index) { } I have created strutcture of Contact with name and surname both string on the start of the program.