CArray::Add causes a compiler error

I'm having some issues with the CArray class.  It seems to be attempting to access a private member in CObject when I use the Add function.  The error I get is
error C2248: 'CObject::operator`='' : cannot access private member declared in class 'CObject'      
The error apparently occurs on line 529 of atlsimpstr.h, which is this function:
PCXSTR GetString() const throw()
      return( m_pszData );
Anyways, the relevant code from the program is as follows:

typedef struct tagITEMMAP
    DWORD Index;
    tagITEMMAP *Parent;
    CArray<tagITEMMAP, tagITEMMAP&> Children;

void Whatever(LPITEMMAP Item)
    ITEMMAP Temp;
    Temp.Parent = Item;
    Temp.Index = Entries[Item->Index].FirstIndex;

When I compile the program I get the following error:
error C2248: 'CObject::CObject': cannot access private member declared in class 'CObject'

This error is caused by the line Item->Children.Add(Temp);
since when it is commented out the program compiles and runs fine.
I am using the beta of Visual Studio 2005 (8.0.40607.16), but the error occurs in 2003 as well.

Thanks in advance for any help.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It seems to me that CArray is missing a =operator and not Temp but copy of it is tried to be added to the array. the copy of temp does make a shallow copy of CArray which should fail. Or have you supplied a =operator () for struct tagITEMMAP which knows how to copy the array?
The safer approach would be to have a CArray <LPITEMMAP, LPITEMMAP> which stores the pointer. Creation of the objects is now entirely up to you to code.
Your code requires copying of the whole ITEMMAP structure by Array.Add function. However, one of members of ITEMMAP is CArray. So, CArray instance must be copied using operator=, which is not allowed.
Your design looks strange: CArray is kind of list or variable-size array. Item kept in this array have CArray member - why? It looks like manually created linked list:

struct ListItem
    ListItem* next;

But you don't need this, CArray takes care about members order. What are you trying to do?
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

DarkSnoopyAuthor Commented:
I intended to copy the whole Temp object when it's added because the actual code goes into a loop where it adds many items to Item->Children, all with the same value for parent.  Since the memory should already be allocated for the items by the SetSize function, I didn't want to use CArray <LPITEMMAP, LPITEMMAP> because it adds the extra hassle of taking care of memory allocation myself.  I'll try writing an =operator() for tagITEMMAP when I get a chance, but I'm in class right now... will be back in a couple hours and hopefully I can accept your answer.

AlexFM, the function is parsing through the directory map of a filesystem.  The value of Index is not the same as the index of the child, it is the index of the entry in the directory map, and the parent value is a pointer to the parent object in the filesystem.  The CArray is used so I can easily traverse the directory structure and only have to create the structure once instead of parsing the directory map several times.  The need for Index is to be able to access the file from the directory structure that is created.  If you can think of an easier way to do this that would avoid this mess that would be helpful too, but this is the easiest thing I could think to do.
You don't need to take care about memory management but you need to write the copy operator of a CArray which I doubt is simple and needing to copy the array content. When it is always empty as in this case this should not be a problem. Only if files get moved you will have problems.

But what is so difficult in the memory handling? In each call to add you need to have
LPITEMMAP Temp = new tagITEMMAP ();
Temp->Parent = Item;

And when destroying the list you need to delete all those items. But I think that way is much clearer.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DarkSnoopyAuthor Commented:
It worked excellently, thank you very much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.