right
Got it. Fix the error but there is something else with it. Look at the code. Some trouble with nodes I believe
#include<iostream>
#include<conio.h>
#define MaxSize 30
using namespace std;
struct Node
{
char name[MaxSize];
Node* link;
};
class Q
{
public:
void get_input(char array[]);
void print_input();
private:
Node* head;
void display(Node* );
};
int main()
{
Q q;
cout<<"We are goig to fill an linked list with nodes, and then switch the :";
cout<<"order between them, we will pick which wat words are go where? ";
q.get_input("Joe");
q.get_input("Marry");
q.get_input("Brat");
q.get_input("Smith");
q.get_input("Guy");
q.get_input("Josh");
q.print_input();
getch();
return 0;
}
void Q::get_input(char array[])
{
Node* temp;
temp=new Node;
strcpy(temp->name,array);
temp->link=head;
head=temp;
}
void Q::print_input()
{
cout<<"The output is : ";
display(head);
}
void Q::display(Node* head)
{
if (head=NULL)
return ;
else
cout<<head->name<<" ";
display(head->link);
}
Reputation Points: 20
Solved Threads: 0
Junior Poster in Training
Offline 66 posts
since Jan 2007