Home > Back-end >  Structure of the vector into why there will be a problem?
Structure of the vector into why there will be a problem?

Time:09-28

Is the following code:
Out of it when I use buf is new push_back a Node * there will be a problem, and I'm buf is directly in the global area declare there is no problem:
 # include 
# include
# include
# include
# include
# include
# include
# include
# include
Using namespace STD.
The class Node {
Public:
VectorVector Cost;
Vector The count.
};//buf [1000].

Int main () {
Freopen (" F://Temp/input. TXT ", "r", stdin);
Int n, m;
Cin & gt;> N & gt;> m;
Node * buf=new Node [n].//so below (1) other complains
For (int I=0; I & lt; N - 1; + + I) {//there are n - 1 road
Int s, t, c;
Cin & gt;> S & gt;> T & gt;> C;
Buf [s]. Cost. The push_back (c);
Void * p;
Node Node * TMP=new (p);
Buf [s]. Next. Push_back (TMP);//(1)
}
return 0;
}

There is the following error: under VS2013

Ask what the problem is, my classmates and I couldn't think what the problem with the accident at the mirror for a long time,
  • Related