problem facing with vector in c++

typedef struct node
{
int data;
node(int x)
{
data = x;
}
}node;

typedef node* NODE;


main()
{
vector<<vector<NODE> >a;
vector<NODE> b;
NODE ob = new node(1);
NODE ob1 = new node(2);
b.push_back(ob);
b.push_back(ob1);
vector<NODE>::iterator it;
it=b.begin();
a[0].assign(it,b.end());
}

the code is getting crashed at above mentioned bold line
a[0].assign(it,b.end());

Can anybody help me to sort it out.

Because the a vector has zero elements in it. operator[] does not create elements.

BTW, in C++, you do not want to do

1
2
3
typedef struct foo
{
} foo;


Just do

1
2
3
struct foo
{
};

got ur point jsmith....

thanks .............
Topic archived. No new replies allowed.