c++ - Does MFC CList support the copy assignment? -


i've looked clist definition in msvc afxtempl.h , document on msdn. did not see clist& operator=(const clist&); defined.

can directly use operator= copy clist object this?

 clist<int> = b; 

or should iterate source clist manually head tail , addtail on target clist?

 for(position pos = a.headposition(); pos; )  {       const auto& item = a.getnext(pos);       b.addtail(item);  } 

any suggestions helpful. thanks.

if copy assignment operator isn't defined, isn't defined , can't used. that's true clist, you've observed, no, can't use operator= copy clist object. if want deep copy of collection, need write function manually.

but consider whether want deep copy. of time, you'll want pass collection types reference, rather value. true in mfc, can contain objects derived cobject can't copied. in fact, you'll notice copying explicitly disallowed cobject class, using private copy constructor , assignment operator:

   // disable copy constructor , assignment default    //   compiler errors instead of unexpected behaviour if pass objects    //   value or assign objects. private:    cobject(const cobject& objectsrc);              // no implementation    void operator=(const cobject& objectsrc);       // no implementation 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -