I do not even know how to start debugging this, from the example I have I cannopt see a problem, and the error messages might as well just say hey there was an error go fetch, oh and good luck were as cluseless as you are.
code:
Code:
#include <iostream>
#include <string>
#include <cstddef>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
template<class T>
struct Node
{
string Name;
T data;
Node *Next;
};
typedef Node* NodePtr;
template<class T>
void Insert(NodePtr after, T MyStuff);
template<class T>
void Insert(NodePtr Head, string AfterName, T MyStuff, string MyName);
template<class T>
void Insert(NodePtr Head, int AfterIDX, T MyStuff, string MyName);
template<class T>
void Insert(NodePtr Head&, T MyStuff, string MyName);
template<class T>
T Get(NodePtr Head, string name);
template<class T>
T Get(NodePtr Head, int IDX);
int main()
{
cout << "bleh!";
return 0;
}
template<class T>
void Insert(NodePtr after, T MyStuff, string MyName) //initially I copied this structure from 15-13, not an exact copy, but a copy of the idea.
{
NodePtr temp; //declare a new node
temp = new Node; //initilize the new node
temp->data = MyStuff; // Give the new node its data
temp->Name = MyName; // Give the new node its name
temp->Next = after->Next; // Connect the nodes after the new one to the new one
after->Next = temp; //connect the new node to the ones that came before it
}
template<class T>
void Insert(NodePtr Head, string AfterName, T MyStuff, string MyName)
{
NodePtr temp; //declare a new node
NodePtr after; //make an empty pointer that will contain a reference to the needed node of the linked list.
temp = new Node; //initilize the new node
temp->data = MyStuff; // Give the new node its data
temp->Name = MyName; // Give the new node its name
after = Get(Head, AfterName); //get the node that should be in here
temp->Next = after->Next; // Connect the nodes after the new one to the new one
after->Next = temp; //connect the new node to the ones that came before it
}
template<class T>
void Insert(NodePtr Head, int AfterIDX, T MyStuff, string MyName)
{
NodePtr temp; //declare a new node
NodePtr after; //make an empty pointer that will contain a reference to the needed node of the linked list.
temp = new Node; //initilize the new node
temp->data = MyStuff; // Give the new node its data
temp->Name = MyName; // Give the new node its name
after = Get(Head, AfterIDX); //get the node that should be in here
temp->Next = after->Next; // Connect the nodes after the new one to the new one
after->Next = temp; //connect the new node to the ones that came before it
}
template<class T>
void Insert(NodePtr& Head, T MyStuff, string MyName)
{
NodePtr temp; //declare a new node
temp = new Node; //initilize the new node
temp->data = MyStuff; // Give the new node its data
temp->Name = MyName; // Give the new node its name
temp->Next = Head; // Connect the nodes after the new one to the new one
Head = temp; //connect the new node to the ones that came before it
}
template<class T>
T Get(NodePtr Head, string name)
{
NodePtr temp;
temp = Head;
while (Head->Next != NULL)
{
if (Head->Name == name)
{
return temp;
}
temp = temp->next;
}
cout << "Error! no such name!";
exit(1);
}
template<class T>
T Get(NodePtr Head, int IDX)
{
NodePtr temp;
temp = Head;
int counter = 0;
while (counter < IDX)
{
temp = temp->next;
counter++;
if (temp->next == NULL)
{
cout << "Error! no such name!";
exit(1);
}
}
return temp;
}
error:
assign5.cpp:18: syntax error before `*' token
assign5.cpp:21: syntax error before `,' token
assign5.cpp:24: syntax error before `,' token
assign5.cpp:27: syntax error before `,' token
assign5.cpp:30: syntax error before `&' token
assign5.cpp:33: syntax error before `,' token
assign5.cpp:36: syntax error before `,' token
assign5.cpp:45: syntax error before `,' token
assign5.cpp: In function `void Insert(...)':
assign5.cpp:47: syntax error before `;' token
assign5.cpp:48: syntax error before `;' token
assign5.cpp: At global scope:
assign5.cpp:56: syntax error before `,' token
assign5.cpp:57: redefinition of `template<class T> void Insert(...)'
assign5.cpp:46: `template<class T> void Insert(...)' previously declared here
assign5.cpp: In function `void Insert(...)':
assign5.cpp:58: syntax error before `;' token
assign5.cpp:60: syntax error before `;' token
assign5.cpp: At global scope:
assign5.cpp:69: syntax error before `,' token
assign5.cpp:70: redefinition of `template<class T> void Insert(...)'
assign5.cpp:57: `template<class T> void Insert(...)' previously declared here
assign5.cpp:70: redefinition of `template<class T> void Insert(...)'
assign5.cpp:46: `template<class T> void Insert(...)' previously declared here
assign5.cpp: In function `void Insert(...)':
assign5.cpp:71: syntax error before `;' token
assign5.cpp:73: syntax error before `;' token
assign5.cpp: At global scope:
assign5.cpp:82: syntax error before `,' token
assign5.cpp:83: redefinition of `template<class T> void Insert(...)'
assign5.cpp:70: `template<class T> void Insert(...)' previously declared here
assign5.cpp:83: redefinition of `template<class T> void Insert(...)'
assign5.cpp:57: `template<class T> void Insert(...)' previously declared here
assign5.cpp:83: redefinition of `template<class T> void Insert(...)'
assign5.cpp:46: `template<class T> void Insert(...)' previously declared here
assign5.cpp: In function `void Insert(...)':
assign5.cpp:84: syntax error before `;' token
assign5.cpp:85: syntax error before `;' token
assign5.cpp: At global scope:
assign5.cpp:93: syntax error before `,' token
assign5.cpp: In function `T Get(...)':
assign5.cpp:95: syntax error before `;' token
assign5.cpp: At global scope:
assign5.cpp:110: syntax error before `,' token
assign5.cpp:111: redefinition of `template<class T> T Get(...)'
assign5.cpp:94: `template<class T> T Get(...)' previously declared here
assign5.cpp: In function `T Get(...)':
assign5.cpp:112: syntax error before `;' token