HI
i have a small problem but for some reason i can't think of how to do it.
I'm making a linear linked list of arrays. The Array is of travel class object. So in the struct node, how should i implement so that the size of the array is allocate "dynamically"?

struct node										
{												
	char		* data;
	travel		* travelPtr;					
	node		* next;							

	node(char *in)								
	{
		data = in;								
		next = NULL;				
	}

	node(travel *aPtr)							
	{
                ?????
                next= NULL;
        }
};

usually with string i do something like

node (char *string)
{
          Array = new char[strlen(string)+1];
          strcpy(Array,string);
          next = NULL;
}

right? but i can't think of how i can do this with array of objects

Thanks in advance

Member Avatar for jencas

Use templates.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.