So, I am trying to use CArray
like this :
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 is coming from.
HELP!
The error you are getting is because you are trying to use a CArray
as a return value from what I can gather. If you change it from returning a CArray
to taking a reference parameter instead, that will compile.
Try this:
class CPerson
{
public:
CPerson();
CPerson(int i);
void operator=(const CPerson& p) {}
private:
char* m_strName;
};
CPerson::CPerson()
{}
CPerson::CPerson(int i)
{
sprintf(m_strName,"%d",i);
}
void aFunction(CArray<CPerson,CPerson&> &allPersons)
{
for(int i=0;i<10;i++)
{
allPersons.SetAtGrow(i,CPerson(i));
i++;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With