Home » Community » Coffee corner » Strange program crash
Re: Strange program crash [message #39177 is a reply to message #39176] |
Sat, 23 February 2013 05:06   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
code in c
struct node *RowHeader[MAX_ROW];
more likely translates to
typedef struct node Node;
// actually, in C you need the struct, in
// c++, it can be opted out
// so
// typedef node Node;
// is the same
Vector<Node*> RootHeader;
However, you may want to put the dynamically allocated node* into some smart pointer so that they will be delete'd (free'd).
or you can do it yourself
class MyNodeContainer : public Vector<node*>
{
public:
~MyNodeContainer()
{
for(int i=0; i<GetCount(); ++i)
delete (*this)[i];
// or free((*this)[i]); if the nodes are malloc'ed
}
and other method, eg, constructors,..
}
[Updated on: Sat, 23 February 2013 05:29] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 03 05:23:13 CEST 2025
Total time taken to generate the page: 0.03777 seconds
|