> > here the code:
> > #include <iostream>
> > #include <vector>
> > #include <cstring>
> > #include <list>
> > #include <algorithm>
> >
> > #include "compat.h"
> > using namespace std;
> >
> > int main()
> > {
> > //vector<char*> coll1;
> >   list<int>    coll1;
> >   vector<int>    coll2;
> >
> > for (int i=1 ; i<=9; i++)
> >   
> May be it is more c-idiomatic to use [0, 9 [  (or [0, 9 ( notation )
range
> > {
> > coll1.push_back(i);
> > }
> >
> > copy(coll1.begin(),coll1.end(),coll2.begin());
> >   
> there is a bug here.
> copy do not reserve space in col2
> either resize col2, or use a back_inserter

you can use the vector constructor which use range too.


> 
> > //for (int i=1 ; i<=9; i++)
> >   
> take care not to use i for the operator[] directly.
> 
> > cout << coll2.begin;
> >
> >   
> you missed the parentheses col2.begin()

te be more precise, you probably want to display the value
and not the iterator, so use *
cout << (*coll2.begin()) << endl;

> 
> > I have used > gcc -c -g file.cpp
> > and g++ as well
> >
> > Hussein
> >
> >   
> 
> use g++ for compiling C++
> it helps a lot
> 
> Gurus will help you further
> David
>


Reply via email to