Hi thefirstrepairdad, This happens because method overloading ( u used correct term) does not distinguish two functions/methods only by return type. It is always based on number or/and type of arguments. you need to change your function syntax. How about making return type as void for both and passing DATA/ENTRY as argument?
Thanks Srinimand On Thu, Aug 27, 2009 at 4:50 PM, thefirstrepairdad <[email protected]>wrote: > > > Hi all, > > I built a set of routines to manage linked lists and used overloading (I > think that's the correct terminology for what I've done) to allow calling > the "same" function using different data types. > > Here's an example of what works: > > extern void dump_list(FILE *, DATA *llist); > extern void dump_list(FILE *, ENTRY *llist); > extern void dump_list(FILE *, const DATA *llist, long int count); > extern void dump_list(FILE *, const ENTRY *llist, long int count); > > ... > > void dump_list(FILE *fp, struct DATA *llist) > { > dump_list(fp, (struct DATA *)llist, 0L); > } > > void dump_list(FILE *fp, struct ENTRY *llist) > { > dump_list(fp, llist, 0L); > } > > void dump_list(FILE * fp, const DATA *llist, long int count) > { > struct DATA *tlist = (struct DATA *)llist; > struct DATA *plist = (struct DATA *)NULL; > long int iter = 0L; > > ... > } > > void dump_list(FILE * fp, const ENTRY *llist, long int count) > { > struct ENTRY *tlist = (struct ENTRY *)llist; > struct ENTRY *plist = (struct ENTRY *)NULL; > long int iter = 0L; > ... > } > > But if I try to initialize a list, and return the appropriate data type, > thusly: > > extern struct DATA *initialize_list(void); > extern struct ENTRY *initialize_list(void); > > and call it with > > struct DATA *Dlist = initialize_list(); > > or > > struct ENTRY *Elist = initialize_list(); > > I get errors saying: > "new declaration 'ENTRY* initialize_list()'" > "ambiguates old declaration 'DATA* initialize_list()'" > > I assume because this function has no arguments, it can't determine which > version to use? Is there a way to do this? Do I need to pass an unused > argument to "set" the data type and just ignore it? As: > > extern struct DATA *initialize_list(const DATA *llist); > extern struct ENTRY *initialize_list(const ENTRY *llist); > > Thank you, > > ~Rick > > > [Non-text portions of this message have been removed]
