Showing posts from June, 2021

How To Remove A Value From C++ Vectors (Value Based Remove)

Hi guys, if you are working with vectors in CPP you may require some usage of vectors. For example removing a value from vector is some of them. In CPP vectors, there are two delete method.  One of them erase other is remove.  When you wanted to use "erase" you should consider "erase function only takes pointer" of the value. For example I have a vector like this: vector<string> blogkafem = {"h", "e", "l", "l", "o"}; If I decide to use erase function, at first I should get address of the value with pointer. For using pointers in vectors you should use begin() function. What does begin() function? It takes pointer value of the first element in the vector. After you get first element of the vector, you can discover other vectors easily. Let's do it! vector::<string>iterator iteratorOfVector = blogkafem.begin(); "iteratorOfVector" is a pointer. If you want to print it with "cout" you