Re: Linked list problem



On Sat, 15 Oct 2005 11:15:28 -0700, "Peter Schmitz"
<PeterSchmitz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>HI,
>
>I tried to do the following:
>
>struct TESTLIST {
> ULONG anynumber;
> CStringArray mystrings;
>};
>
>std::list<TESTLIST> mylinkedlist;
>
>
>Now, when I try to compile this, I receive the following error:
>
>c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\include\list(34): error
>C2558: struct 'TESTLIST': no copy constructor available or copy constructor
>is declared 'explicit'....
>
>Can anyone help me out of this?

Standard containers require the types they store to be copy constructible.
Your problem is with CStringArray, which hasn't got an accessible copy ctor
and is preventing instantiation of the default copy ctor for TESTLIST. You
might be able to write a copy ctor for TESTLIST (BTW, all caps
conventionally names a macro) that uses CStringArray::Copy, or you might
simply use std::vector<CString> as a substitute for CStringArray.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Why do I need a copy constructor?
    ... I managed to get it to compile by creating the copy methods but now it won't ... It is looking for the .ctor for each of my classes. ... You don't need a copy constructor. ... Is B complete at newB (i.e. is the class body for it ...
    (microsoft.public.vc.language)
  • Re: Me vs. MyClass
    ... >| ctor. ... > the constructor as the base constructor calls it before the derived ... > I really don't see how MyClass adds or takes away support to calling ...
    (microsoft.public.dotnet.languages.vb)
  • Re: limited types (Was: Records that could be arrays)
    ... The constructor is wrapped by the function. ... you cannot ensure the wrapper will always be called for some ... Containers of class-wide types ... own ctor, if only to call the ctor of the base class. ...
    (comp.lang.ada)
  • Re: do allocators have to be stateless?
    ... BUT i do not want to use a global pool as we're going multi-threaded and each thread will have it's own pool. ... // copy constructor ... the compiler appears to be trying to use the regular construtor constructor when it should be using the copy constructor. ...
    (microsoft.public.vc.stl)
  • C# Thread safety
    ... (whidbey beta 1). ... CLI guarantee that all state updates performed within a constructor be ... can return an uninitialized object if the CLR chooses to perform the ... What I want to know is, is this a bug in Visual Studio 2005 beta 1? ...
    (microsoft.public.dotnet.languages.csharp)