Hi
I try to fill linked list with names. I have one error could anyone fix it.
#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;
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);
}
the error I have is:
44 C:\Documents and Settings\mauro\Desktop\c++\nodes- read names switched them around and display them.cpp expected primary-expression before ']' token
thx