Is there a unique MFC protection that keeps an object to another class from modifying its private data?
I have a CStringArray in the my document class (single-document). I pass the CStringArray object to class function belonging to another object that I instantiate inside of the document class.
For example:
#include myOutsideClass;
void CMyClassDoc::change()
{
myOutsideClass *pClass = new myOutsideClass;
pClass->modify(myCStringArrayObject);
}
-----
// Definition of modify()
void CMyOutsideClass(CStringArray &array)
{
array.RemoveAll(); // remove all data from object array
array.Add("testing"); // insert "testing" into object array
}
-----
Notice I pass the CStringArray object into modify using reference. Function modify(CStringArray &array) can read data from the object array. However, it cannot make permanent changes such as RemoveAll(), Add(), and/or SetAt().
Is there a internal protection algorithm that keeps another object from making permanent changes to a member object? I tried declaring the CStringArray inside of CDocument in public. That does not work either. The program crashes with an *access violation* error.
Thanks,
Kuphryn