View Single Post
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Genreic Double Linked List Using Templates

 
0
  #4
Nov 22nd, 2008
I see. I think it's not the best problem area to try generic functions. You are trying to declare a family of related functions implemented some generic data structure. But it's exactly a class notion. Now your efforts demonstrated a disparity of a goal and tools.

When we need generic functions? We want a generic unit of functionality - for example, generic sort array operation...

Apropos, don't use by value parameters in program cases as in following code:
  1. ... append(node<type>** l,type elem) {
  2. ... Q->data=elem;
No need in argument copying, use references:
  1. ... append(node<type>** l,const type& elem) {
Yet another remark(s): print_l function requires operator << for template argument class. Why? There are lots of data classes without such operator but now you can't use them with your functions package. Avoid such names as print_l: simply look at print_l and print_1 (different ) names...
Reply With Quote