"error C2248: 'CObject :: CObject': cannot access the private member declared in the class 'CObject'

Possible duplicate:
using CArray

Duplicate: error using CArray


so I am trying to use CArray as follows:

   CArray<CPerson,CPerson&> allPersons;
   int i=0;
   for(int i=0;i<10;i++)
   {
      allPersons.SetAtGrow(i,CPerson(i));
      i++;
   }

but when compiling my program, I get this error:

"error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtempl.h"

I don’t even understand where this comes from.

HELP!

+2
source share
3 answers

Write a constructor for your class (CPerson) and make it public. he must solve the problem.

+2
source

, CObject . - CArray, "&". . :

void DoFoo(CArray cArr)
{
    // Do something to cArr...
}

^^^ .

void DoFoo(CArray & cArr)
{
    // Do something to cArr...
}

^^^ .

+19

This means that your program is trying to create an instance CObjectthat seems to be prohibited because it CObjecthas a private constructor.

Maybe CArraytrying to build these instances? What does the rest of the program look like?

+1
source

All Articles