Templates are the ideal solution for this, but probably bejond your current level of expertise.
Another posibility is to use conditional compilation. For example you woudl place the following code in a header some where. (I'm not sure I understand the maining all your files etc, so I don't know where).
#ifndef LISTITEMDEFINDED
struct dataTypeList
{
int value;
int multiple;
};
typedef dataTypeList itemListType;
#endif
Then if you want to use the structure in the linked list, and don't need to do anything special. If you want to use another type in the linked list, you just need to place a like like
#define LISTITEMDEFINED
before the include file that has the text above. You also need to create an appropriate typedef for the itemListType.
Main Topics
Browse All Topics





by: mnewtonPosted on 2000-04-25 at 17:49:04ID: 2749789
The struct statement should be in list.h. You can't do what you are trying to do. In order to create the two different lists that you want you will need to either use a template class or create two different list classes.
Actually, I just has a thought. If your programs are in two separate directories you could define your list type in a header file (lets call it data.h). Your list class header file would include data.h. Your two programs would each have their own copy of list.h, list.cpp, and data.h. The list files would be identical, only the data.h files would be different.
I think that a template is probably the best solution though.