assignment is recursive call and placing strings in link list notes

Pages: 12
You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.



The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.



Write a driver to test the permute class to pass in any two strings of any sizes.



Other than mention in the following, you can add more classes, functions, and private data members to this program.



Note class

The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.



Permute class

The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.



There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.



Driver file

The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";
And? What's the problem you're having with your code?
i have written code but it gives me a bunch of errors:
the program should run like this :
also i do i attach i pic on the content so i can tell what im tryin to get
Well, how are we supposed to help you fix those errors, if you don't show us the code?

I don't think you can attach pics here, by the way. The forum software is pretty basic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
ok ill the code one by one becasue its too long
//File: linked_list.h

#include "linked_list.h"
 
namespace CISP430 {
 
string charList_join(const char* glue, linked_list<char> pieces) {
string joined = "";
for (int i=0; i<pieces.size(); ++i) {
       if (i==0) { 
            joined += pieces.get(i); 
         }
     else {
     
       joined += glue;
       joined += pieces.get(i);
      }
   }
     return joined;
}
 

//file node.h//
#ifndef NODE_H
#define NODE_H
 
#include <cstdlib> 
#include <iterator>
using namespace std;
 
namespace CISP430
{
 template <class Item>
 class node
 {
 public:
// TYPEDEF
 typedef Item value_type;
// CONSTRUCTOR
 node(const Item& init_data=Item( ), node* init_link=NULL) {
 data_field = init_data; link_field = init_link;
 }
 // MODIFICATION MEMBER FUNCTIONS
 Item& data( ) { return data_field; }
 node* link( ) { return link_field; }
 void set_data(const Item& new_data) { data_field = new_data; }
 void set_link(node* new_link) { link_field = new_link; }
 // CONST MEMBER FUNCTIONS
 const Item& data( ) const { return data_field; }
 const node* link( ) const { return link_field; }
 private:
 Item data_field;
 node *link_field;
  };
 
// FUNCTIONS to manipulate a linked list:
 template <class Item>
 void list_clear(node<Item>*& head_ptr);
 
 template <class Item>
 void list_copy
 (const node<Item>* source_ptr, node<Item>*& head_ptr, node<Item>*& tail_ptr);
 
template <class Item>
void list_head_insert(node<Item>*& head_ptr, const Item& entry);
 
 template <class Item>
 void list_head_remove(node<Item>*& head_ptr);
 
 template <class Item>
 void list_insert(node<Item>* previous_ptr, const Item& entry);
  template <class Item>
 size_t list_length(const node<Item>* head_ptr);
 
 template <class NodePtr, class SizeType>
 NodePtr list_locate(NodePtr head_ptr, SizeType position);
 
 template <class Item>
 void list_remove(node<Item>* previous_ptr);
 template <class NodePtr, class Item>
 NodePtr list_search(NodePtr head_ptr, const Item& target);
 
 template <class Item>
 class node_iterator
 // : public std::iterator<std::forward_iterator_tag, Item>
 {
 public:
 node_iterator(node<Item>* initial = NULL) {
 current = initial;
 }
 Item& operator *( ) const { return current->data( ); }
 node_iterator& operator ++( ) { // Prefix ++
  current = current->link( );
 return *this;
 }
  node_iterator operator ++(int) { // Postfix ++
  node_iterator original(current);
 current = current->link( );
 return original;
 }
 bool operator ==(const node_iterator other) const {
 return current == other.current;
 }
 bool operator !=(const node_iterator other) const {
  return current != other.current;
}
  private:
 node<Item>* current;
 };
 
 template <class Item>
 class const_node_iterator
 // : public std::iterator<std::forward_iterator_tag, const Item>
 {
 public:
   const_node_iterator(const node<Item>* initial = NULL) { current = initial; }
  const Item& operator *( ) const { return current->data( ); }
  const_node_iterator& operator ++( ) { // Prefix ++
  current = current->link( );
   return *this;
  }
  const_node_iterator operator ++(int) { // Postfix ++
  const_node_iterator original(current);
  current = current->link( );
   return original;
  }
  bool operator ==(const const_node_iterator other) const {
  return current == other.current;
  }
  bool operator !=(const const_node_iterator other) const {
    return current != other.current;
  }
  private:
  const node<Item>* current;
 };
 
}
#include "node.template"
#endif
}
Last edited on
Please can you use code tags when posting code, to make it readable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//file:permute_append.cpp//
#include <cstdlib> // Provides size_t // included in permute_append.h
#include <sstream> // provides the << operator for string concatenation. // not using
#include <string> //provides string type //included in permute_append.h
#include "permute_append.h"
#include "node.template"
 
namespace CISP430 {
 
/*CONSTRUCTORS, DECONSTRUCTOR*/
permute_append::permute_append() {
firstString = "CAT"; // x is just a default value
secondString = "MAN"; // x is just a default value
total = 0;
}
permute_append::permute_append(const char* first, const char* second) {
firstString = first;
secondString = second;
total = 1; // at least one permutation
for (int i=firstString.length(); i>0; --i) { // number of permutations is equal to factorial of the number of characters in firstString
total *= i;
}
/*Turn string into linked list of chars*/
for (int i=0; i<firstString.length(); ++i) {
permute_me.add(firstString[i]);
}
}
permute_append::permute_append(const permute_append &source) {
firstString = source.firstString;
secondString = source.secondString;
total = source.total;
permute_me = source.permute_me;
result_list = source.result_list;
}
permute_append::~permute_append() {
total = 0;
firstString = "";
secondString = "";

}
linked_list<string> permute_append::permute(linked_list<char> charList) { // permute the characters in the array (n items, n at a time)

static linked_list<string> perms; static linked_list<char> usedChars;
linked_list<char> character;
for (int i = 0; i < charList.size(); ++i) {
character = list_splice(charList, i, 1); //??? How do we pass charList to list_splice so list_splice modifies charList directly? Answer: just like I did.
usedChars.add( character.get(0) );
if (charList.size() == 0) perms.add( charList_join("", usedChars) ); //??? Is charList_join() working? I believe so.
permute(charList);
list_splice( charList, i, 0, character.get(0) );
list_pop( usedChars );
}
return perms;
}

string permute_append::do_it() {
result_list
linked_list<string> perms( permute(permute_me) ); // ??? How do you point to the returned linked_list properly?

for (size_t i=0; i<perms.size(); ++i) {

result_list.add(perms.get(i) + secondString);
}
}
string permute_append::do_it(const char* first, const char* second) {
firstString and stores each result in result_list
firstString = first; secondString = second;
do_it();
}
string permute_append::get(size_t position) { // get a result
return result_list.get(position);
}
}

//file:permute_append.h//
#include <cstdlib> // Provides size_t
#include <string> // provides string type (C++ class)
#include "linked_list.h" // provides linked_list
using namespace std;
 
 
namespace CISP430_A5 {
class permute_append {
public:
/*CONSTRUCTORS, DESTRUCTOR*/
permute_append();
permute_append(const char* first, const char* second);
permute_append(const permute_append &source);
~permute_append();
/*Returns a linked_list of string items, each item a permutation of the chars in the charList argument*/
linked_list<string> permute(linked_list<char> charList); // permute the characters in charList (n items, n at a time)
string do_it();
// appends secondString to each permutation of firstString and stores each result in result_list
string do_it(const char* first, const char* second);
// set firstString and secondString then appends secondString to each permutation of firstString and stores each result in result_list
string get(size_t position);
/*Get the item at position position from result_list*/
 
private:
size_t total;
string firstString;
string secondString;
linked_list<char> permute_me;
linked_list<string> result_list;
};
} 

//file main.cpp//
#include <string> // provides the string type (class)
#include <iostream> // provides cout, etc.
using namespace std;
#include "linked_list.h" // provides linked_list
#include "permute_append.h" // provides permute_append
 

using namespace CISP430;
 

//int main(void) {
 
// linked_list<int> items;
// items.add(10);
// items.add(30);
// items.add(20);
// items.add(40);
 
// /* for each item in the list:*/
// for (int i=0; i<items.size(); ++i) {
// cout << items.get(i) << endl;
// }
// cout << "-----------------------" << endl;
// items.set(2, 50);
// /* item at position 2 is now 50. */
// cout << items.get(2) << endl;
// cout << "-----------------------" << endl;
// items.add(23);
// items.add(16);
// items.add(34);
// items.remove(2);
// for (int i=0; i<items.size(); ++i) {
// cout << items.get(i) << endl;
// }
// cout << "-----------------------" << endl;
 
// items.remove(4);
// for (int i=0; i<items.size(); ++i) {
// cout << items.get(i) << endl;
// }
// } 
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
//file: linked_list.h//
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
 
#include <cstdlib> // Provides size_t
#include <string> // allows usage of the string type
#include "node.h" // Provides node class
using namespace std;
 
namespace CISP430
{
template <typename Item>
class linked_list

{
public:
/* TYPEDEFS and MEMBER CONSTANTS: */
typedef Item value_type;
/* CONSTRUCTORS and DESTRUCTOR: */
linked_list( );
linked_list(const linked_list& source);
~linked_list( );
/* MODIFICATION MEMBER FUNCTIONS */
/*ADDED:*/
value_type get(size_t position); // get item at position x
void set(size_t position, const value_type& entry); // set item at position x, if past boundaries, just modify at beginning or at end.
void add(const value_type& entry); // add to the end of list
void insert(size_t position, const value_type& entry); // set item at position x, if past boundaries, just insert at beginning or attach at end.
void attach(size_t position, const value_type& entry); // set item at position x, if past boundaries, just insert at beginning or attach at end.
void remove(size_t position);
/*REMOVED:*/
/*void remove_current( );*/
/*void start( );*/
/*void advance( );*/
/*void insert(const value_type& entry);*/
/*void attach(const value_type& entry);*/
/*STAYS THE SAME:*/
void operator=(const linked_list& source);
/* CONSTANT MEMBER FUNCTIONS */
/*STAYS THE SAME:*/
value_type current( ) const;
size_t size( ) const { return many_nodes; }
bool is_item( ) const { return (cursor != NULL); }
 
private:
/*PRIVATE HELPER FUNCTIONS*/
/*ADDED:*/
void remove_current( );
void start( );
void advance( );
void insert_here(const value_type& entry); // same as insert() from sequence. insert at current position.
void attach_here(const value_type& entry); // same as attach() from sequence. attach at current position.
/*PRIVATE VARIABLES*/	
/*STAYS THE SAME:*/
node<Item> *cursor;
node<Item> *precursor;
node<Item> *head_ptr;
node<Item> *tail_ptr;
size_t many_nodes;
};
 
/*Linked List Tools*/
template <typename Item>
linked_list<Item> list_splice(linked_list<Item> &input, size_t offset, size_t length);
template <typename Item>
linked_list<Item> list_splice(linked_list<Item> &input, size_t offset, size_t length, Item new_item);
template <typename Item>
linked_list<Item> list_splice(linked_list<Item> &input, size_t offset, size_t length, linked_list<Item> new_items);
/*template prefix not needed here since the second parameter names a specific type for the linked_list*/
string charList_join(const char* glue, linked_list<char> pieces);
template <typename Item>
typename linked_list<Item>::value_type list_pop(linked_list<Item> list);
}
 
 
 
 
 
/* Sample usage:
int main(void) {
 
linked_list items = new linked_list;
items.attach(10);
items.insert(30);
items.attach(20);
items.insert(40);
 
// for each item in the list:
for (int i=0; i<items.size(); ++i) {
cout << items.get(i) << endl;
}
items.set(2, 50);
// item at position 2 is now 50.
}
*/
// The implementation of a template class must be included in its header file:
#include "linked_list.template"
#endif



//file: node.template//
// FILE: node.template
// IMPLEMENTS: The functions of the node template class and the
// linked list toolkit (see node2.h for documentation).
//
// NOTE:
// Since node is a template class, this file is included in node2.h.
// Therefore, we should not put any using directives in this file.
//
// INVARIANT for the node class:
// The data of a node is stored in data_field, and the link in link_field.
 
#include <cassert> // Provides assert
#include <cstdlib> // Provides NULL and size_t
 
namespace CISP430_A5
{
template <class Item>
void list_clear(node<Item>*& head_ptr)
// Library facilities used: cstdlib
{
while (head_ptr != NULL)
list_head_remove(head_ptr);
}
 
template <class Item>
void list_copy(
const node<Item>* source_ptr,
node<Item>*& head_ptr,
node<Item>*& tail_ptr
)
// Library facilities used: cstdlib
{
head_ptr = NULL;
tail_ptr = NULL;
// Handle the case of the empty list
if (source_ptr == NULL)
return;
 
// Make the head node for the newly created list, and put data in it
list_head_insert(head_ptr, source_ptr->data( ));
tail_ptr = head_ptr;
// Copy rest of the nodes one at a time, adding at the tail of new list
source_ptr = source_ptr->link( );
while (source_ptr != NULL)
{
list_insert(tail_ptr, source_ptr->data( ));
tail_ptr = tail_ptr->link( );
source_ptr = source_ptr->link( );
}
}
template <class Item>
void list_head_insert(node<Item>*& head_ptr, const Item& entry)
{
head_ptr = new node<Item>(entry, head_ptr);
}
 
template <class Item>
void list_head_remove(node<Item>*& head_ptr)
{
node<Item> *remove_ptr;
 
remove_ptr = head_ptr;
head_ptr = head_ptr->link( );
delete remove_ptr;
}
 
template <class Item>
void list_insert(node<Item>* previous_ptr, const Item& entry)
{
node<Item> *insert_ptr;
insert_ptr = new node<Item>(entry, previous_ptr->link( ));
previous_ptr->set_link(insert_ptr);
}
 
template <class Item>
size_t list_length(const node<Item>* head_ptr)
// Library facilities used: cstdlib
{
const node<Item> *cursor;
std::size_t answer;
answer = 0;
for (cursor = head_ptr; cursor != NULL; cursor = cursor->link( ))
++answer;
return answer;
}
 
template <class NodePtr, class SizeType>
NodePtr list_locate(NodePtr head_ptr, SizeType position)
// Library facilities used: cassert, cstdlib
{
NodePtr cursor;
SizeType i;
assert(0 < position);
cursor = head_ptr;
for (i = 1; (i < position) && (cursor != NULL); ++i)
cursor = cursor->link( );
return cursor;
}
 
template <class Item>
void list_remove(node<Item>* previous_ptr)
{
node<Item> *remove_ptr;
 
remove_ptr = previous_ptr->link( );
previous_ptr->set_link(remove_ptr->link( ));
delete remove_ptr;
}
 
template <class NodePtr, class Item>
NodePtr list_search(NodePtr head_ptr, const Item& target)
// Library facilities used: cstdlib
{
NodePtr cursor;
for (cursor = head_ptr; cursor != NULL; cursor = cursor->link( ))
if (target == cursor->data( ))
return cursor;
return NULL;
}
}
Last edited on
linked_list.template
first part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include <iostream>
using namespace std;

namespace CISP430 {
	
	template <class Item>
	linked_list<Item>::linked_list() {
		head_ptr = NULL;
		tail_ptr = NULL;
		cursor = NULL;
		precursor = NULL; // no need for this if Node objects have a "previous" link field.
		many_nodes = 0;
	}
	
	template <class Item>
	linked_list<Item>::linked_list( const linked_list& source ) { // copier
		
		int src_size = source.size(); // to replicate cursor position
		int many_til_end = 0; // to replicate cursor position
		int many_til_mid = 0; // to replicate cursor position
		node<Item> *src_cursor = source.cursor; // to replicate cursor position
		
		list_copy(source.head_ptr, head_ptr, tail_ptr);
		
		/*replicate the size value (before cursor position because functions used for that depend on many_nodes value*/
			many_nodes = source.many_nodes;
		
		/*replicate the cursor position*/
			if (src_cursor != NULL) {
				while (src_cursor != NULL) {
					++many_til_end;
					src_cursor = src_cursor->link();
				}
				many_til_mid = src_size - many_til_end; // this is how many to advance to replicate cursor position.
				start(); // put this.cursor at beginning. // DEPENDS ON VALUE OF many_nodes ABOVE
				for (int i=0; i<many_til_mid; ++i) {
					advance(); // DEPENDS ON VALUE OF many_nodes ABOVE
				}
				/* after the for loop, the new linked_list's cursor should be at the same position as the source's cursor was.*/
			}
			else {
				cursor = NULL;
				precursor = NULL;
			}
	}
	
	template <class Item>
	linked_list<Item>::~linked_list() { // Destructor
		list_clear(head_ptr);
		head_ptr = tail_ptr = cursor = precursor = NULL;
		many_nodes = 0;
	}
			
	/* MODIFICATION MEMBER FUNCTIONS */
	
	template <class Item>
	void linked_list<Item>::start() {
		if (many_nodes > 0) { // if at least one item exists
			cursor = head_ptr;
			precursor = NULL;
		}
	}
	
	template <class Item>
	void linked_list<Item>::advance() {
		if (is_item()) {
			precursor = cursor;
			cursor = cursor->link();
			if ( cursor == NULL ) {
				precursor = NULL;
			}
		}
	}
	

		template <class Item>
		typename linked_list<Item>::value_type linked_list<Item>::get(int position) {
			for (int i=0; i<=position; ++i) { // advance the cursor to the position then return item
				if (i==0)
					start();
				else
					advance();
				
				if (i==position) {
					return current();
				}
			}
		}
		
		template <class Item>
		void linked_list<Item>::set(int position, const value_type& entry) {
			if (is_item()) { // only set at a valid position.
			
				insert(position, entry); // insert new item to list
				
				advance();
				remove_current(); // remove old item from list.
			}
		}
		
		template <class Item>
		void linked_list<Item>::add(const value_type& entry) {
			cursor = precursor = NULL; // remove cursor
			attach_here(entry); // <<-- attaches at end when no cursor.
		}
		
		template <class Item>
		void linked_list<Item>::remove(int position) {
			for (int i=0; i<=position; ++i) { // advance the cursor to the position then insert item
				if (i==0)
					start();
				else
					advance();
				
				if (i==position) {
					remove_current();
				}
			}
		}
		
		template <class Item>
		void linked_list<Item>::insert(int position, const value_type& entry) {
			for (int i=0; i<=position; ++i) { // advance the cursor to the position then insert item
				if (i==0)
					start();
				else
					advance();
				
				if (i==position) {
					insert_here(entry);
				}
			}
		}
	/*
	]
	*/
	
	template <class Item>
	void linked_list<Item>::insert_here(const value_type &entry) {
	/*REMOVED*/
		// void linked_list<Item>::insert(const value_type &entry) {
		
		/*if the list is empty*/
		if (!is_item() && !many_nodes) {
			cursor = new node<Item>(entry);
			head_ptr = cursor;
			tail_ptr = cursor;
		}
		
		/*if the list is not empty and cursor points to the first item*/
		else if (is_item() && cursor == head_ptr) {
			cursor = new node<Item>( entry );
			cursor->set_link( head_ptr );
			head_ptr = cursor;
		}
		
		/*if the list is not empty and there is no current item*/
		else if (!is_item() && many_nodes) {
			cursor = new node<Item>( entry );
			cursor->set_link( head_ptr );
			head_ptr = cursor;
		}
		
		/*if the list is not empty and the cursor points somewhere in 
			the middle(including last item)*/
		else if (is_item() && cursor != head_ptr) {
			cursor = new node<Item>( entry );
			cursor->set_link( precursor->link() );
			precursor->set_link( cursor );
		}
		
		++many_nodes; //increase the node count
	}
	
	/*ADDED*/
		template <class Item>
		void linked_list<Item>::attach(int position, const value_type& entry) {
			for (int i=0; i<=position; ++i) { // advance the cursor to the position then attach item
				if (i==0)
					start();
				else
					advance();
				
				if (i==position) {
					attach_here(entry);
				}
			}
		}
	
	template <class Item>
	void linked_list<Item>::attach_here(const value_type& entry) {
	/*REMOVED*/
		// void linked_list<Item>::attach(const value_type& entry) {
		
		/*if the list is empty*/
		if (!is_item() && !many_nodes) {
			cursor = new node<Item>(entry);
			head_ptr = cursor;
			tail_ptr = cursor;
			precursor = NULL;
		}
		
		/*if the list is not empty and cursor points to the first item and there's only one item*/
		else if (is_item() && many_nodes == 1) {
			cursor = new node<Item>( entry );
			cursor->set_link( head_ptr->link() );
			head_ptr->set_link( cursor );
			precursor = head_ptr;
			tail_ptr = cursor;
		}
		
		/*if the list is not empty and cursor points to the first item and there's more than one item*/
		else if (is_item() && many_nodes > 1 && cursor == head_ptr ) {
			cursor = new node<Item>( entry );
			cursor->set_link( head_ptr->link() );
			head_ptr->set_link( cursor );
			precursor = head_ptr;
		}
		
		/*if the list is not empty and there is no current item*/
		else if (!is_item() && many_nodes) {
			cursor = new node<Item>( entry );
			tail_ptr->set_link( cursor );
			precursor = tail_ptr;
			tail_ptr = cursor;
		}
second part of linked_list.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
	/*if the list is not empty and the cursor points somewhere in 
			the middle(including last item)*/
		else if (is_item() && cursor != head_ptr) {
			if (cursor != tail_ptr) { // if cursor is not at last item
				cursor = new node<Item>( entry );
			}
			else if (cursor == tail_ptr) { // if cursor is at last item
				cursor = new node<Item>( entry );
				tail_ptr = cursor;
			}
			cursor->set_link( (precursor->link())->link() );
			(precursor->link())->set_link( cursor );
			precursor = precursor->link();
		}
		
		++many_nodes; // increase the node count
	}
	
	template <class Item>
	void linked_list<Item>::remove_current() {
		if ( is_item() ) {
			
			/*If the cursor points to an item in the middle of the list, not tail, not head:*/
			if (cursor != head_ptr && cursor != tail_ptr) {
				precursor->set_link( cursor->link() );
				delete cursor;
				cursor = precursor->link();
			}
		
			/*If the cursor points to the first item in the list and that is the only item:*/
			else if (many_nodes == 1) {
				delete cursor;
				cursor = head_ptr = tail_ptr = precursor = NULL;
			}
			
			/*If the cursor points to the first item in the list and there is more than one item:*/
			else if ( cursor == head_ptr && many_nodes > 1) {
				cursor = cursor->link();
				delete head_ptr;
				head_ptr = cursor;
			}
			
			/*If the cursor points to the last item in the list (and there is more than one item)*/
			else if ( cursor == tail_ptr && many_nodes > 1) {
				delete cursor;
				tail_ptr = precursor;
				/* #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!# */
				tail_ptr->set_link(NULL);
				/* #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!# */
				precursor = cursor = NULL;
			}
			
			--many_nodes;
		}
	}
	
	template <class Item>
	void linked_list<Item>::operator =(const linked_list& source) {
		if (this != &source) {
			list_clear(head_ptr);
			head_ptr = tail_ptr = cursor = precursor = NULL;
			many_nodes = 0;
		
			int src_size = source.size(); // to replicate cursor position
			int many_til_end = 0; // to replicate cursor position
			int many_til_mid = 0; // to replicate cursor position
			node<Item> *src_cursor = source.cursor; // to replicate cursor position
			
			list_copy(source.head_ptr, head_ptr, tail_ptr);
			
			/*replicate the size value (before cursor position because functions used for that depend on many_nodes value*/
				many_nodes = source.many_nodes;
			
			/*replicate the cursor position*/
				if (src_cursor != NULL) {
					while (src_cursor != NULL) {
						++many_til_end;
						src_cursor = src_cursor->link();
					}
					many_til_mid = src_size - many_til_end; // this is how many to advance to replicate cursor position.
					start(); // put this.cursor at beginning.
					for (int i=0; i<many_til_mid; ++i) {
						advance();
					}
					/* after the for loop, the new linked_list's cursor should be at the same position as the source's cursor was.*/
				}
				else {
					cursor = NULL;
					precursor = NULL;
				}
		}
	}
			
	/* CONSTANT MEMBER FUNCTIONS */
	
	template <class Item>
	typename linked_list<Item>::value_type linked_list<Item>::current() const {
		if ( is_item() ) {
			return cursor->data();
		}
	}

}
and here is the output of the should look like:
String 1 for this object is:
String 2 for this object is:
There is no permutation.



String 1 for this object is:
String 2 for this object is: CATMAN
The total possible permutation is 1
That is:
CATMAN

String 1 for this object is: C
String 2 for this object is: ATMAN
The total possible permutation is 1
That is:
CATMAN

String 1 for this object is: CA
String 2 for this object is: TMAN
The total possible permutation is 2
They are:
ACTMAN CATMAN

String 1 for this object is: CAT
String 2 for this object is: MAN
The total possible permutation is 6
They are:
TACMAN ATCMAN CTAMAN TCAMAN
ACTMAN CATMAN

String 1 for this object is: CATM
String 2 for this object is: AN
The total possible permutation is 24
They are:
MTACAN TMACAN AMTCAN MATCAN
TAMCAN ATMCAN CMTAAN MCTAAN
TCMAAN CTMAAN MTCAAN TMCAAN
ACMTAN CAMTAN MACTAN AMCTAN
CMATAN MCATAN TACMAN ATCMAN
CTAMAN TCAMAN ACTMAN CATMAN


String 1 for this object is: CATMA
String 2 for this object is: N
The total possible permutation is 120
They are:
AMTACN MATACN TAMACN ATMACN MTAACN TMAACN AAMTCN AAMTCN MAATCN
AMATCN AMATCN MAATCN TAAMCN ATAMCN ATAMCN TAAMCN AATMCN AATMCN
MTAACN TMAACN AMTACN MATACN TAMACN ATMACN CAMTAN ACMTAN MCATAN
CMATAN AMCTAN MACTAN TCAMAN CTAMAN ATCMAN TACMAN CATMAN ACTMAN
MTCAAN TMCAAN CMTAAN MCTAAN TCMAAN CTMAAN AMTCAN MATCAN TAMCAN
ATMCAN MTACAN TMACAN ACAMTN CAAMTN AACMTN AACMTN CAAMTN ACAMTN
MACATN AMCATN CMAATN MCAATN ACMATN CAMATN AMACTN MAACTN AAMCTN
AAMCTN MAACTN AMACTN CAMATN ACMATN MCAATN CMAATN AMCATN MACATN
TACAMN ATCAMN CTAAMN TCAAMN ACTAMN CATAMN ATACMN TAACMN AATCMN
AATCMN TAACMN ATACMN CATAMN ACTAMN TCAAMN CTAAMN ATCAMN TACAMN
ACATMN CAATMN AACTMN AACTMN CAATMN ACATMN MTACAN TMACAN AMTCAN
MATCAN TAMCAN ATMCAN CMTAAN MCTAAN TCMAAN CTMAAN MTCAAN TMCAAN
ACMTAN CAMTAN MACTAN AMCTAN CMATAN MCATAN TACMAN ATCMAN CTAMAN
TCAMAN ACTMAN CATMAN

String 1 for this object is: CATMAN
String 2 for this object is:
The total possible permutation is 720
They are:
NAMTAC ANMTAC MNATAC NMATAC AMNTAC MANTAC TNAMAC NTAMAC ATNMAC
TANMAC NATMAC ANTMAC MTNAAC TMNAAC NMTAAC MNTAAC TNMAAC NTMAAC
AMTNAC MATNAC TAMNAC ATMNAC MTANAC TMANAC ANAMTC NAAMTC AANMTC
AANMTC NAAMTC ANAMTC MANATC AMNATC NMAATC MNAATC ANMATC NAMATC
AMANTC MAANTC AAMNTC AAMNTC MAANTC AMANTC NAMATC ANMATC MNAATC
NMAATC AMNATC MANATC TANAMC ATNAMC NTAAMC TNAAMC ANTAMC NATAMC
ATANMC TAANMC AATNMC AATNMC TAANMC ATANMC NATAMC ANTAMC TNAAMC
NTAAMC ATNAMC TANAMC ANATMC NAATMC AANTMC AANTMC NAATMC ANATMC
MTANAC TMANAC AMTNAC MATNAC TAMNAC ATMNAC NMTAAC MNTAAC TNMAAC
NTMAAC MTNAAC TMNAAC ANMTAC NAMTAC MANTAC AMNTAC NMATAC MNATAC
TANMAC ATNMAC NTAMAC TNAMAC ANTMAC NATMAC AMTANC MATANC TAMANC
ATMANC MTAANC TMAANC AAMTNC AAMTNC MAATNC AMATNC AMATNC MAATNC
TAAMNC ATAMNC ATAMNC TAAMNC AATMNC AATMNC MTAANC TMAANC AMTANC
MATANC TAMANC ATMANC CNAMTA NCAMTA ACNMTA CANMTA NACMTA ANCMTA
MCNATA CMNATA NMCATA MNCATA CNMATA NCMATA AMCNTA MACNTA CAMNTA
ACMNTA MCANTA CMANTA NAMCTA ANMCTA MNACTA NMACTA AMNCTA MANCTA
TCNAMA CTNAMA NTCAMA TNCAMA CNTAMA NCTAMA ATCNMA TACNMA CATNMA
ACTNMA TCANMA CTANMA NATCMA ANTCMA TNACMA NTACMA ATNCMA TANCMA
CNATMA NCATMA ACNTMA CANTMA NACTMA ANCTMA MTCNAA TMCNAA CMTNAA
MCTNAA TCMNAA CTMNAA NMTCAA MNTCAA TNMCAA NTMCAA MTNCAA TMNCAA
CNMTAA NCMTAA MCNTAA CMNTAA NMCTAA MNCTAA TCNMAA CTNMAA NTCMAA
TNCMAA CNTMAA NCTMAA AMTCNA MATCNA TAMCNA ATMCNA MTACNA TMACNA
CAMTNA ACMTNA MCATNA CMATNA AMCTNA MACTNA TCAMNA CTAMNA ATCMNA
TACMNA CATMNA ACTMNA MTCANA TMCANA CMTANA MCTANA TCMANA CTMANA
NAMTCA ANMTCA MNATCA NMATCA AMNTCA MANTCA TNAMCA NTAMCA ATNMCA
TANMCA NATMCA ANTMCA MTNACA TMNACA NMTACA MNTACA TNMACA NTMACA
AMTNCA MATNCA TAMNCA ATMNCA MTANCA TMANCA ACNAMT CANAMT NACAMT
ANCAMT CNAAMT NCAAMT AACNMT AACNMT CAANMT ACANMT ACANMT CAANMT
NAACMT ANACMT ANACMT NAACMT AANCMT AANCMT CNAAMT NCAAMT ACNAMT
CANAMT NACAMT ANCAMT MACNAT AMCNAT CMANAT MCANAT ACMNAT CAMNAT
NMACAT MNACAT ANMCAT NAMCAT MANCAT AMNCAT CNMAAT NCMAAT MCNAAT
CMNAAT NMCAAT MNCAAT ACNMAT CANMAT NACMAT ANCMAT CNAMAT NCAMAT
AMACNT MAACNT AAMCNT AAMCNT MAACNT AMACNT CAMANT ACMANT MCAANT
CMAANT AMCANT MACANT ACAMNT CAAMNT AACMNT AACMNT CAAMNT ACAMNT
MACANT AMCANT CMAANT MCAANT ACMANT CAMANT NAMACT ANMACT MNAACT
NMAACT AMNACT MANACT ANAMCT NAAMCT AANMCT AANMCT NAAMCT ANAMCT
MANACT AMNACT NMAACT MNAACT ANMACT NAMACT AMANCT MAANCT AAMNCT
AAMNCT MAANCT AMANCT CNAMAT NCAMAT ACNMAT CANMAT NACMAT ANCMAT
MCNAAT CMNAAT NMCAAT MNCAAT CNMAAT NCMAAT AMCNAT MACNAT CAMNAT
ACMNAT MCANAT CMANAT NAMCAT ANMCAT MNACAT NMACAT AMNCAT MANCAT
TACNAM ATCNAM CTANAM TCANAM ACTNAM CATNAM NTACAM TNACAM ANTCAM
NATCAM TANCAM ATNCAM CNTAAM NCTAAM TCNAAM CTNAAM NTCAAM TNCAAM
ACNTAM CANTAM NACTAM ANCTAM CNATAM NCATAM ATACNM TAACNM AATCNM
AATCNM TAACNM ATACNM CATANM ACTANM TCAANM CTAANM ATCANM TACANM
ACATNM CAATNM AACTNM AACTNM CAATNM ACATNM TACANM ATCANM CTAANM
TCAANM ACTANM CATANM NATACM ANTACM TNAACM NTAACM ATNACM TANACM
ANATCM NAATCM AANTCM AANTCM NAATCM ANATCM TANACM ATNACM NTAACM
TNAACM ANTACM NATACM ATANCM TAANCM AATNCM AATNCM TAANCM ATANCM
CNATAM NCATAM ACNTAM CANTAM NACTAM ANCTAM TCNAAM CTNAAM NTCAAM
TNCAAM CNTAAM NCTAAM ATCNAM TACNAM CATNAM ACTNAM TCANAM CTANAM
NATCAM ANTCAM TNACAM NTACAM ATNCAM TANCAM ACNATM CANATM NACATM
ANCATM CNAATM NCAATM AACNTM AACNTM CAANTM ACANTM ACANTM CAANTM
NAACTM ANACTM ANACTM NAACTM AANCTM AANCTM CNAATM NCAATM ACNATM
CANATM NACATM ANCATM MTACNA TMACNA AMTCNA MATCNA TAMCNA ATMCNA
CMTANA MCTANA TCMANA CTMANA MTCANA TMCANA ACMTNA CAMTNA MACTNA
AMCTNA CMATNA MCATNA TACMNA ATCMNA CTAMNA TCAMNA ACTMNA CATMNA
NMTACA MNTACA TNMACA NTMACA MTNACA TMNACA ANMTCA NAMTCA MANTCA
AMNTCA NMATCA MNATCA TANMCA ATNMCA NTAMCA TNAMCA ANTMCA NATMCA
MTANCA TMANCA AMTNCA MATNCA TAMNCA ATMNCA CNMTAA NCMTAA MCNTAA
CMNTAA NMCTAA MNCTAA TCNMAA CTNMAA NTCMAA TNCMAA CNTMAA NCTMAA
MTCNAA TMCNAA CMTNAA MCTNAA TCMNAA CTMNAA NMTCAA MNTCAA TNMCAA
NTMCAA MTNCAA TMNCAA ACNMTA CANMTA NACMTA ANCMTA CNAMTA NCAMTA
MACNTA AMCNTA CMANTA MCANTA ACMNTA CAMNTA NMACTA MNACTA ANMCTA
NAMCTA MANCTA AMNCTA CNMATA NCMATA MCNATA CMNATA NMCATA MNCATA
TACNMA ATCNMA CTANMA TCANMA ACTNMA CATNMA NTACMA TNACMA ANTCMA
NATCMA TANCMA ATNCMA CNTAMA NCTAMA TCNAMA CTNAMA NTCAMA TNCAMA
ACNTMA CANTMA NACTMA ANCTMA CNATMA NCATMA AMTACN MATACN TAMACN
ATMACN MTAACN TMAACN AAMTCN AAMTCN MAATCN AMATCN AMATCN MAATCN
TAAMCN ATAMCN ATAMCN TAAMCN AATMCN AATMCN MTAACN TMAACN AMTACN
MATACN TAMACN ATMACN CAMTAN ACMTAN MCATAN CMATAN AMCTAN MACTAN
TCAMAN CTAMAN ATCMAN TACMAN CATMAN ACTMAN MTCAAN TMCAAN CMTAAN
MCTAAN TCMAAN CTMAAN AMTCAN MATCAN TAMCAN ATMCAN MTACAN TMACAN
ACAMTN CAAMTN AACMTN AACMTN CAAMTN ACAMTN MACATN AMCATN CMAATN
MCAATN ACMATN CAMATN AMACTN MAACTN AAMCTN AAMCTN MAACTN AMACTN
CAMATN ACMATN MCAATN CMAATN AMCATN MACATN TACAMN ATCAMN CTAAMN
TCAAMN ACTAMN CATAMN ATACMN TAACMN AATCMN AATCMN TAACMN ATACMN
CATAMN ACTAMN TCAAMN CTAAMN ATCAMN TACAMN ACATMN CAATMN AACTMN
AACTMN CAATMN ACATMN MTACAN TMACAN AMTCAN MATCAN TAMCAN ATMCAN
CMTAAN MCTAAN TCMAAN CTMAAN MTCAAN TMCAAN ACMTAN CAMTAN MACTAN
AMCTAN CMATAN MCATAN TACMAN ATCMAN CTAMAN TCAMAN ACTMAN CATMAN

Press any key to continue . . .
need help i have post the codes above
http://www.eelis.net/iso-c++/testcase.xhtml
I really have no motivation in going through all that code, ¿is there a good reason why you can't use `std::list' ?
i have tried tht but didnt work i think its code it should be simple. can you help with the codes
gives me a bunch of errors:
What errors and when?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 part one
1>  permute_append.cpp
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(95): error C2244: 'CISP430_A5::linked_list<Item>::get' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(33) : see declaration of 'CISP430_A5::linked_list<Item>::get'
1>          definition
1>          'linked_list<Item>::value_type CISP430_A5::linked_list<Item>::get(int)'
1>          existing declarations
1>          'Item CISP430_A5::linked_list<Item>::get(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(106): error C2244: 'CISP430_A5::linked_list<Item>::set' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(34) : see declaration of 'CISP430_A5::linked_list<Item>::set'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::set(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::set(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(126): error C2244: 'CISP430_A5::linked_list<Item>::remove' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(38) : see declaration of 'CISP430_A5::linked_list<Item>::remove'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::remove(int)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::remove(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(140): error C2244: 'CISP430_A5::linked_list<Item>::insert' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(36) : see declaration of 'CISP430_A5::linked_list<Item>::insert'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::insert(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::insert(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(195): error C2244: 'CISP430_A5::linked_list<Item>::attach' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(37) : see declaration of 'CISP430_A5::linked_list<Item>::attach'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::attach(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::attach(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(23): error C2995: 'void CISP430_A5::list_clear(CISP430_A5::node<Item> *&)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(177) : see declaration of 'CISP430_A5::list_clear'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(50): error C2995: 'void CISP430_A5::list_copy(const CISP430_A5::node<Item> *,CISP430_A5::node<Item> *&,CISP430_A5::node<Item> *&)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(181) : see declaration of 'CISP430_A5::list_copy'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(55): error C2995: 'void CISP430_A5::list_head_insert(CISP430_A5::node<Item> *&,const Item &)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(184) : see declaration of 'CISP430_A5::list_head_insert'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(65): error C2995: 'void CISP430_A5::list_head_remove(CISP430_A5::node<Item> *&)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(187) : see declaration of 'CISP430_A5::list_head_remove'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(73): error C2995: 'void CISP430_A5::list_insert(CISP430_A5::node<Item> *,const Item &)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(190) : see declaration of 'CISP430_A5::list_insert'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(85): error C2995: 'size_t CISP430_A5::list_length(const CISP430_A5::node<Item> *)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(192) : see declaration of 'CISP430_A5::list_length'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(98): error C2995: 'NodePtr CISP430_A5::list_locate(NodePtr,SizeType)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(195) : see declaration of 'CISP430_A5::list_locate'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(108): error C2995: 'void CISP430_A5::list_remove(CISP430_A5::node<Item> *)' : function template has already been defined
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
part two
>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(198) : see declaration of 'CISP430_A5::list_remove'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.template(119): error C2995: 'NodePtr CISP430_A5::list_search(NodePtr,const Item &)' : function template has already been defined
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\node.h(200) : see declaration of 'CISP430_A5::list_search'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\permute_append.cpp(23): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\permute_append.cpp(46): warning C4018: '<' : signed/unsigned mismatch
1>  main.cpp
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(95): error C2244: 'CISP430_A5::linked_list<Item>::get' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(33) : see declaration of 'CISP430_A5::linked_list<Item>::get'
1>          definition
1>          'linked_list<Item>::value_type CISP430_A5::linked_list<Item>::get(int)'
1>          existing declarations
1>          'Item CISP430_A5::linked_list<Item>::get(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(106): error C2244: 'CISP430_A5::linked_list<Item>::set' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(34) : see declaration of 'CISP430_A5::linked_list<Item>::set'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::set(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::set(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(126): error C2244: 'CISP430_A5::linked_list<Item>::remove' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(38) : see declaration of 'CISP430_A5::linked_list<Item>::remove'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::remove(int)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::remove(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(140): error C2244: 'CISP430_A5::linked_list<Item>::insert' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(36) : see declaration of 'CISP430_A5::linked_list<Item>::insert'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::insert(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::insert(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(195): error C2244: 'CISP430_A5::linked_list<Item>::attach' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(37) : see declaration of 'CISP430_A5::linked_list<Item>::attach'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::attach(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::attach(size_t,const Item &)'
1>  linked_list.cpp
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(95): error C2244: 'CISP430_A5::linked_list<Item>::get' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(33) : see declaration of 'CISP430_A5::linked_list<Item>::get'
1>          definition
1>          'linked_list<Item>::value_type CISP430_A5::linked_list<Item>::get(int)'
1>          existing declarations
1>          'Item CISP430_A5::linked_list<Item>::get(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(106): error C2244: 'CISP430_A5::linked_list<Item>::set' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(34) : see declaration of 'CISP430_A5::linked_list<Item>::set'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::set(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::set(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(126): error C2244: 'CISP430_A5::linked_list<Item>::remove' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(38) : see declaration of 'CISP430_A5::linked_list<Item>::remove'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::remove(int)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::remove(size_t)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(140): error C2244: 'CISP430_A5::linked_list<Item>::insert' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(36) : see declaration of 'CISP430_A5::linked_list<Item>::insert'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::insert(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::insert(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.template(195): error C2244: 'CISP430_A5::linked_list<Item>::attach' : unable to match function definition to an existing declaration
1>          c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.h(37) : see declaration of 'CISP430_A5::linked_list<Item>::attach'
1>          definition
1>          'void CISP430_A5::linked_list<Item>::attach(int,const Item &)'
1>          existing declarations
1>          'void CISP430_A5::linked_list<Item>::attach(size_t,const Item &)'
1>c:\users\krrish\documents\visual studio 2010\projects\krishneelca5cisp43013f\krishneelca5cisp43013f\linked_list.cpp(7): warning C4018: '<' : signed/unsigned mismatch
You have two kind of issues.
The first one is that you are a liar.
unable to match function definition to an existing declaration
'void CISP430_A5::linked_list<Item>::remove(int)'
existing declarations
'void CISP430_A5::linked_list<Item>::remove(size_t)'
size_t is not the same as int

The second one, you put the template definitions in another file which is included at the end of the correspondent header file.
However, sources are including your template definition on their own. Because your file is not designed to be included it is causing those `already defined' errors.
Either don't include files that you are not supposed to include, or put header guards in your template definitions.


PS: please note how your issue hold no relationship to the thread title or the first post.
You should have said that you were trying to implement a linked list, but it failed to compile.

Also, when posting such a volume of code, consider using github or similar instead.
Last edited on
@ ne555
can you tell me which files :Either don't include files that you are not supposed to include, or put header guards in your template definitions."
permute_append.cpp is including node.template, but node.template has no header guard
Pages: 12