C++ 打印出我的链表会打印出它的内存位置

C++ 打印出我的链表会打印出它的内存位置,c++,C++,好的,我必须读入一个文件date.dat,它存储一个日期和相应的时间 例如) 这是我的代码,可以读入: 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.fai

好的,我必须读入一个文件date.dat,它存储一个日期和相应的时间

例如)

这是我的代码,可以读入:

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 to 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();

}
有什么帮助吗?我完全不知道。谢谢

接线员是:

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;
}
模板

你写的代码“C++”,除非我的眼睛欺骗了我,C++什么时候有嵌套函数?我正在查看您的
orderedInsert
函数——它包含另一个函数
FillList
。这个C++是通过在代码>操作符中的const引用传递您的对象<代码>代码> /COD>,现在将是在调试器中逐步通过代码的一个恒星时间。再说一遍,这是什么语言?因为像<代码>这样的东西。当前的< /C> >根本不是标准C++。@ JSKOZNOLION<代码>删除这个< /代码>这是在拷贝复制器中应该做什么?另外,这一切不都归结为
retrieve
函数实际上在做什么吗?这就是最终获得输出数据的地方。
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);
}
void DisplayList(linkedList<myDate> list)
{
  cout << endl;
  cout << list;
}
     ======= 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
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
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;
  }    
}
//retrieve
template <class T>
bool linkedList<T>::retrieve(T &value) const
{
  if(current==NULL)
    return false;
  else
    {
      value=current->data;
      return true;
    }

}