c++ - How to implement functions with container list -
i'm learning container list. , want write function replace (element on index), insert (element on index), , want know how delete them. i'm learning 2 day watched videos , read articles don't know how write code. know how list work's pointers.
this how imagined (it start)
void replace(list<contact> &listof, int index, const contact &information) { for(list<int>::iterator = listof.begin(); != listof.end(); it++){ } } i don't know if loop writen right, imagined go through list , if finds index wants replace juse overwrite.
i think function insert has same parameters.
and how imagined delete i'm not quit sure how implement.
contact delete(list<contact> &listof, int index) { } i have created strutcture of contact name , surname both string on start of program.
the loop should written
for (list<contact>::iterator = listof.begin(); != listof.end(); ++it) { wan't *it. }
Comments
Post a Comment