CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Help Experts!

  1. #1
    Join Date
    Apr 1999
    Posts
    74

    Help Experts!

    Why the compile error? WorkCodes is CArray of CWorkCode. ERROR READS "afxtempl.h(443) : error C2582: 'CWorkCode' : 'operator =' function is unavailable" Would appreciate any help! Thanks!

    void CTimeView::OnEditAddEdit()
    {
    CTimeDoc* pDoc = GetDocument();
    CWorkCodeDialog wcd;
    wcd.DoModal();
    CWorkCode wc(wcd.m_strWorkCode, wcd.m_strDescription);
    pDoc->WorkCodes.Add(wc);<-------COMPILE ERROR!

    }


  2. #2
    Join Date
    Apr 1999
    Posts
    383

    Re: Help Experts!

    CArray::Add requires the added type to have an assignment operator

    You need to provide at least a copy constructor and an assignment operator in your class if you are storing it by value.

    Dave




  3. #3
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: Help Experts!

    You need to specify a copyconstructor. When you declare an non-pointer array, then the array stores a copy of the element.

    If you don't want to create a copyconstructor, then you have to make an array of pointers to your class.


  4. #4
    Join Date
    Apr 1999
    Posts
    74

    Dave, Thanks very much!

    eom


  5. #5
    Join Date
    Apr 1999
    Posts
    74

    Franky, thanks a bunch!

    eom



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured