Linked list problem while taking input
Whats wrong here? The compiler says,
Data does not name a type. |
Question: How can I add some info instead of a single value as a node in Linked List?
Please help. Thanks for any comment.
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
|
#include <iostream>
using namespace std;
class Course{
private:
string title;
string days;
string time;
Data value;
Course *next;
public:
Data input(Data item)
{
cout<<endl;
cout<<"Enter course title: ";
getline(cin, item.title);
cout<<"Mention days for the course: ";
cin>>item.days;
cout<<"Mention time of the course: ";
cin>>item.time;
return item;
}
void add_course(Course *&head, Data x)
{
if(!head){
head = new Course;
head->value = x;
head->next = NULL;
}
else
return add_course(head->next , x);
}
};
int main(){
Course *head = NULL, A;
Data item, n;
item = A.input(n);
A.add_course(head, item);
return 0;
}
|
Well, there is no type named Data defined anywhere. Ming tellying what Data is and how should we know about it in advance?
Topic archived. No new replies allowed.