A large part of your problem appears to be a misunderstanding - or simply lack of understanding - of how vectors work. You also seem to have a penchant for the dangerous practice of storing vector iterators as class members instead of using local variables.
Lets take a quick tour of how you use vector:
#include <iostream>
#include <string>
#include <vector>
struct Address
{
int m_doorNo;
std::string m_street;
Address() : m_doorNo(-1), m_street("Limbo")
{
std::cout << "Address() default ctor called\n";
}
Address(int doorNo, const std::string& street)
: m_doorNo(doorNo), m_street(street)
{}
};
// So we can << an Address object.
static std::ostream& operator << (std::ostream& os, const Address& address)
{
os << address.m_doorNo << " " << address.m_street.c_str();
return os;
}
// Give our *usage* of a vector a friendly name.
typedef std::vector<Address> AddressBook;
int main()
{
AddressBook book;
if (book.empty())
std::cout << "book starts empty, it has size() of " << book.size() << '\n';
book.push_back(Address(70, "1st Street"));
std::cout << "First address added, book.size = " << book.size() << '\n';
book.push_back(Address(123, "Hope Avenue"));
std::cout << "Second address added, book.size = " << book.size() << '\n';
std::cout << "address[0] is: " << book[0] << '\n';
std::cout << "address.at(1) is: " << book.at(1) << '\n';
std::cout << "*address.begin() is: " << *(book.begin()) << '\n';
std::cout << "address.front() is: " << book.front() << '\n';
std::cout << "address.back() is: " << book.back() << '\n';
// couple more addresses.
book.insert(book.begin(), Address(3, "Disco Alley"));
book.insert(book.begin() + 1, Address(5, "Mortimer Lane"));
// overshoot, place an extra address at the end of the vector.
book.insert(book.end(), Address(999, "Hellfire Drive"));
// oops, lets erase that.
book.pop_back();
std::cout << "Done shuffling. Size = " << book.size() << " while capacity = " << book.capacity() << '\n';
const size_t numAddrs = book.size();
for (size_t i = 0; i < numAddrs; ++i) {
std::cout << i << ": " << book[i] << '\n';
}
// and lastly, lets use a reverse iterator.
std::cout << "backwards:" << '\n';
// instead of std::vector<Address>::iterator etc, we can say AddressBook::iterator
for (AddressBook::reverse_iterator it = book.rbegin(); it != book.rend(); ++it) {
std::cout << *it << '\n';
}
// 'reserve' adjusts the capacity, it tells the vector to go ahead and
// allocate space for N entries, but don't make them available yet.
book.reserve(999);
// 'resize' changes the size, if the new size is smaller than the capacity,
// it forces a call to reserve to allocate more memory.
// after that, it goes ahead and grows the array storage by default-
// initializing any new entries.
book.resize(9);
std::cout << "book.size = " << book.size() << " but cap = " << book.capacity() << '\n';
// at this point, it is safe to say:
book[6].m_doorNo = 555;
book[7].m_street = "Nowhere";
book[8] = Address(10101, "Binary Bend");
for (auto it = book.begin(); it != book.end(); ++it) {
std::cout << *it << '\n';
}
return 0;
}