Complier error C2280 explanation
-
Hi I have the following collection class (referencing a struct) which is causing the complier error listed below I ended writing my own link list becuase I couldnt resolve the issue however I am hoping that by posting this someone can maybe explain it to me so here is the code listed below is the complier error for some reason the complier doesnt like a Clist template in a struct
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxtempl.h(954,17): error C2280: 'CStorge::buildcombo::tcbholder &CStorge::buildcombo::tcbholder::operator =(const CStorge::buildcombo::tcbholder &)': attempting to reference a deleted function
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc *ablkdescx;
struct blkdesc *fblkdescx;
struct stdecs* nextdecs;}; struct tcbholder { char\* tcb; char programname\[8\]; struct stdecs \*storageptr; CList stptr; };
-
Hi I have the following collection class (referencing a struct) which is causing the complier error listed below I ended writing my own link list becuase I couldnt resolve the issue however I am hoping that by posting this someone can maybe explain it to me so here is the code listed below is the complier error for some reason the complier doesnt like a Clist template in a struct
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include\afxtempl.h(954,17): error C2280: 'CStorge::buildcombo::tcbholder &CStorge::buildcombo::tcbholder::operator =(const CStorge::buildcombo::tcbholder &)': attempting to reference a deleted function
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc *ablkdescx;
struct blkdesc *fblkdescx;
struct stdecs* nextdecs;}; struct tcbholder { char\* tcb; char programname\[8\]; struct stdecs \*storageptr; CList stptr; };
CList
features a deleted copy contructor. Microsoft folks think it is not useful to pass collections by value. You could usestd::list
instead (I believe Microsoft folks themselves recommendstd::list
overCList
)."In testa che avete, Signor di Ceprano?" -- Rigoletto
-
CList
features a deleted copy contructor. Microsoft folks think it is not useful to pass collections by value. You could usestd::list
instead (I believe Microsoft folks themselves recommendstd::list
overCList
)."In testa che avete, Signor di Ceprano?" -- Rigoletto
-
Still get error with list me thinks it has to do that I declared stdecs just as a type without actually allocating storage i.e struct stdecs storagediscriptor; when I have the template outside of a struct it compiles thanks
This works for me:
#include #include using namespace std;
struct Foo
{
list foolist;
};int main()
{
Foo f1;
f1.foolist.push_back(5);
f1.foolist.push_back(7);
Foo f2 = f1;
for (auto i: f2.foolist)
cout << i << " ";
cout << "\n";
}"In testa che avete, Signor di Ceprano?" -- Rigoletto
-
This works for me:
#include #include using namespace std;
struct Foo
{
list foolist;
};int main()
{
Foo f1;
f1.foolist.push_back(5);
f1.foolist.push_back(7);
Foo f2 = f1;
for (auto i: f2.foolist)
cout << i << " ";
cout << "\n";
}"In testa che avete, Signor di Ceprano?" -- Rigoletto