gpt4 book ai didi

c++ - 我收到错误 'TList::operator=' :unable to match function definition to an existing declaration. visual studio community 2017

转载 作者:行者123 更新时间:2023-11-28 01:35:41 25 4
gpt4 key购买 nike

<分区>

我遇到了错误。

TList::operator=':unable to match function definition to an existing declaration.visual studio community 2017. error code: C2244.

错误出现在这个问题的底部,我试图定义复制赋值运算符:

    #include <iostream>
#include <utility>
#include "tnode.h"

// Declaration of class TList

template <typename T>
class TList
{
friend class TListIterator<T>;


public:
TList(); // create empty linked list
TList(T val, int num);// create list with num copies of val
~TList(); // destructor
TList(const TList& L); // copy constructor
TList operator=(const TList& L);// copy assignment operator
TList(TList && L); // move constructor
TList operator=(TList && L);// move assignment operator



private:
Node<T>* first; // pointer to first node in list
Node<T>* last; // pointer to last node in list
int size; // number of nodes in the list
static T dummy; // dummy object, for empty list data returns
// assuming type T has default construction

};




#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
template <typename T>
TList<T>& TList<T>::operator = (const TList& L)
{
size = L.size;
return *this;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com