Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.41 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. //FILE 1
  3.  
  4. if ( temp_cost == root -> cost )
  5.          {
  6.               root -> head -> add_chain( root -> head , name , type );
  7.          }                                    //Head is of type node which is declared in the H file below
  8.  
  9.  
  10.  
  11.  
  12. //FILE 2
  13.  
  14. int node::add_chain(  node *& root ,char * temp_name , char * temp_type )
  15. {  
  16.     node * current ;
  17.     node * previous ;
  18.  
  19.     current = root ;
  20.  
  21.     while ( current )
  22.     {
  23.           previous = current ;  
  24.           current = current -> next ;
  25.     }
  26.  
  27.     current = new node ;
  28.  
  29.     current -> name = new char [ strlen ( temp_name ) + 1 ];
  30.     strcpy_s ( current -> name ,10, temp_name );
  31.    
  32.     current -> type = new char [ strlen ( temp_type ) + 1 ];
  33.     strcpy_s ( current -> type ,10, temp_type );
  34.    
  35.     node::set_next_to_null( current ) ;
  36.  
  37.     previous -> next = current ;
  38.  
  39.     return 1;
  40. }
  41.  
  42.  
  43.  
  44. // H FILE
  45.  
  46. class node
  47. {
  48.       public :
  49.               node();
  50.              
  51.               int add_no_chain( node *& current , char * temp_name , char * temp_type );
  52.               int add_chain(  node *& root ,char * temp_name , char * temp_type );
  53.              
  54.               int display( node * current );
  55.               int set_next_to_null( node *& current );
  56.              
  57.               ~node();
  58.       private :
  59.               char * name ;
  60.               char * type ;
  61.              
  62.               node * next ;
  63. };