S
Simon Elliott
#include <vector>
#include <iostream>
int main (int argc, char *argv[])
{
std::vector<int> vi;
vi.push_back(1);
vi.push_back(2);
vi.push_back(3);
int* pi = vi.begin();
std::cout << "result:" << *pi << std::endl;
return(0);
}
This compiles and runs as I'd expect in Borland C++ Builder 6, but
gives the following error in g++:
test_vectors.cpp:9: error: cannot convert
`__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >' to `int*' in initialization
I can't see where I'm going wrong here: I was under the impression that
random access iterators could be assigned to pointers.
#include <iostream>
int main (int argc, char *argv[])
{
std::vector<int> vi;
vi.push_back(1);
vi.push_back(2);
vi.push_back(3);
int* pi = vi.begin();
std::cout << "result:" << *pi << std::endl;
return(0);
}
This compiles and runs as I'd expect in Borland C++ Builder 6, but
gives the following error in g++:
test_vectors.cpp:9: error: cannot convert
`__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >' to `int*' in initialization
I can't see where I'm going wrong here: I was under the impression that
random access iterators could be assigned to pointers.