Joe Laughlin wrote:
>
These weird errors just keep on coming! Thanks everyone again for your
help.
Please don't tell me this error is because of const again...

But I'd
wager it is.
// 6-9 from Accelerated C++
// Use library algorithm to cat all elements of a vector<string>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
int main()
{
std::vector<std::string> vec;
vec.push_back("Hi!");
vec.push_back(" How ");
vec.push_back("are ");
vec.push_back("you ");
vec.push_back("doing?");
std::string new_string;
copy(vec.begin(), vec.end(), std::back_inserter(new_string));
std::cout << new_string << std::endl;
return 0;
}
g++ -Wall -pedantic -o 6-9 6-9.cpp
/usr/include/c++/3.2.2/bits/stl_algobase.h: In function `_OutputIter
std::__copy(_RandomAccessIter, _RandomAccessIter, _OutputIter,
std::random_access_iterator_tag) [with _RandomAccessIter = std::string*,
_OutputIter = std::back_insert_iterator<std::string>]':
/usr/include/c++/3.2.2/bits/stl_algobase.h:260: instantiated from
`_OutputIter std::__copy_aux2(_InputIter, _InputIter, _
OutputIter, __false_type) [with _InputIter = std::string*, _OutputIter =
std::back_insert_iterator<std::string>]'
/usr/include/c++/3.2.2/bits/stl_algobase.h:303: instantiated from
`_OutputIter std::__copy_ni2(_InputIter, _InputIter, _O
utputIter, __false_type) [with _InputIter = std::string*, _OutputIter =
std::back_insert_iterator<std::string>]'
/usr/include/c++/3.2.2/bits/stl_algobase.h:314: instantiated from
`_OutputIter std::__copy_ni1(_InputIter, _InputIter, _O
utputIter, __true_type) [with _InputIter =
__gnu_cxx::__normal_iterator<std::string*, std::vector<std::string,
std::allocat
or<std::string> > >, _OutputIter = std::back_insert_iterator<std::string>]'
/usr/include/c++/3.2.2/bits/stl_algobase.h:349: instantiated from
`_OutputIter std::copy(_InputIter, _InputIter, _OutputI
ter) [with _InputIter = __gnu_cxx::__normal_iterator<std::string*,
std::vector<std::string, std::allocator<std::string> > >
, _OutputIter = std::back_insert_iterator<std::string>]'
6-9.cpp:22: instantiated from here
/usr/include/c++/3.2.2/bits/stl_algobase.h:241: no match for `
std::back_insert_iterator<std::string>& = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&' operator
/usr/include/c++/3.2.2/bits/stl_iterator.h:355: candidates are:
std::back_insert_iterator<_Container>&
std::back_insert_iterator<_Container>:

perator=(_ Container::const_reference
)
[with _Container = std::string]
/usr/include/c++/3.2.2/bits/stl_iterator.h:330:
std::back_insert_iterator<std::string>&
std::back_insert_iterator<std::string>:

perator=( const
std::back_insert_iterator<std::string>&)