i am new to c++ and learning about vectors now and vector member functions, so my question is more a logical question.

my question is dealing with the .begin() member function, i now it sends the iterator to beginning of vector but i am confused on what it returns. i am thinking it returns a container but a bit unsure


if someone could please clarify this for me please. thanks a lot.

It doesn't "send" anything as far as I know, and if it does, it's probably dependent on the implementation--which you shouldn't concern yourself with.

It "returns" an iterator to the first element in the vector container.

For example:

std::vector<int> myVec(10,7);
std::vector<int>::iterator it = myVec.begin();
for( ; it != myVec.end(); ++it)
{
  std::cout << *it << std::endl;
}

You may want to brush up on iterators.

ya i understand that it returns the iterator to the first spot in the vector my questions stemmed from this practice problem in my book was this:

-the begin() vector member function return a/ an:

it gives options algorithm, iterator, container, enumeration


maybe i explained my question bad but i am not understanding what the correct answer would be,
again thanks for the help

Edited 5 Years Ago by gl7: n/a

This question has already been answered. Start a new discussion instead.