I'm slowly moving from C to C++, and doing this by slowly moving my projects into C++ format. In my current C file I have the following:
struct tag_embdata
{
struct tag_mod_name *Prev;
struct tag_mod_name *Next;
int id;
char *Name;
} *emb_head = NULL, *emb_tail = NULL;
I scan through this linked list regularly searching for various IDs and converting Names to IDs. This list is allocated using malloc, and each Name entry (which is an ASCII null terminated string) is also allocated using malloc.
Now the question - is there a better way of doing this in C++ ? Some people have told me to use iterators, but I don't know what these are.
Secondly, can anyone tell me the advantages and disadvantages of using "new" over "malloc" for creating simple pointers to char (as in the Name element above) ?



LinkBack URL
About LinkBacks



