c++ - Printing out my Linked List prints out its memory location -


okay, have read in file date.dat stores date , corresponding time

eg.)

   12/2/13    05:30 

this code reads in:

void filllist(linkedlist<mydate> &list) {   bool ok = true;   int value;   ifstream f;   string fname;    cout << "file: ";   cin >> fname;   f.open(fname.c_str());   if (f.fail())     {       cout << "failed open" << endl;       return;     }    mydate adate;   mytime atime;   f >> adate;    while (!f.eof())     {       f >> atime;        adate.settime(atime);       list.orderedinsert(adate);       cout<<adate<<endl;       f >> adate;     }    f.close();  } 

the code calls orderedinsert inserts date , time linkedlist , puts in order. orderedinsert here:

template <class t> void linkedlist<t>::orderedinsert(const t &value) {   current=head;    while(current!=null && current->data < value)     {       trailcurrent=current;       current=current->next;     }   if(current!=null)     trailcurrent->data=new node(value,current);   else     head->data=new node(value,current); } 

i want print out list using:

void displaylist(linkedlist<mydate> list) {   cout << endl;   cout << list; } 

but when call displaylist getting memory location of each thing want print out instead of date , time. memory location prints out this:

     ======= memory map: ======== 00400000-00405000 r-xp 00000000 00:18 5508191                            /home/students/jskoz233/prog4/app 00605000-00606000 rw-p 00005000 00:18 5508191                            /home/students/jskoz233/prog4/app 01fbc000-01fdd000 rw-p 00000000 00:00 0                                  [heap] 372ca00000-372ca20000 r-xp 00000000 fd:00 4718921                        /lib64/ld-2.12.so 372cc1f000-372cc20000 r--p 0001f000 fd:00 4718921                        /lib64/ld-2.12.so 372cc20000-372cc21000 rw-p 00020000 fd:00 4718921                        /lib64/ld-2.12.so 

any help? have absolutely no clue. thanks!

operator :

template <class t> ostream &operator<<(ostream &outstream,linkedlist<t> list) {   t element;   this.current=this.head;   while(this.current!=null)     {       element=this.retrieve(element);       outstream<<"["<<element<<"]"<<endl;       this.current++;     }   return outstream; } 

copy constructor:

//copy constructor template <class t> linkedlist<t>::linkedlist(const linkedlist &list) {   node *hurrah;    hurrah=list.head; delete this; while(hurrah!=null)   {       orderedinsert(hurrah->data);       hurrah=hurrah->next;   }     } 

retriev:

//retrieve template <class t> bool linkedlist<t>::retrieve(t &value) const {   if(current==null)     return false;   else     {       value=current->data;       return true;     }  } 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -