关于双向链表的结点类
新手求教,请问这个“c:\users\sebastian\desktop\南开\c++\双向链表\双向链表\doublelinknode.h(29): error C2244: “DoubleLinkNode<T>::operator =”: 无法将函数定义与现有的声明匹配”的错误应该怎么修正。代码如下:
#include<iostream>
using namespace std;
template<class T>
class DoubleLinkNode
{
template<class T>
friend class DoubleLinkList;
public:
DoubleLinkNode()
{
next=NULL;
prev=NULL;
}
void operator = (DoubleLinkNode<T>& a);
T data;
DoubleLinkNode<T> *prev,*next;
};
template<class T>
ostream& operator<<(ostream& out,DoubleLinkNode<T> a)
{
out<<a.data;
return out;
}
template<class T>
void DoubleLinkNode<T>::operator=(DoubleLinkNode<T>& a)
{
data=a.data;
} #include<iostream>
using namespace std;
template<class T>
class DoubleLinkNode
{
friend class DoubleLinkList;
public:
DoubleLinkNode()
{
next=NULL;
prev=NULL;
}
void operator = (DoubleLinkNode<T>& a);
T data;
DoubleLinkNode<T> *prev,*next;
};
template<class T>
ostream& operator<<(ostream& out,DoubleLinkNode<T> a)
{
out<<a.data;
return out;
}
template<class T>
void DoubleLinkNode<T>::operator=(DoubleLinkNode<T>& a)
{
data=a.data;
}
人造人 发表于 2020-5-2 18:40
十分感谢
页:
[1]