This code compile:
////////////////////////////////////////
MyObject.h
////////////////////////////////////////
class MyObject : public CObject
{
public:
MyObject();
~MyObject();
};
////////////////////////////////////////
MyObject.cpp
////////////////////////////////////////
#include "stdafx.h"
#include "myObject.h"
MyObject::MyObject()
{
}
MyObject::~MyObject()
{
}
////////////////////////////////////////
MyClass.h
////////////////////////////////////////
#include <afxtempl.h>
#include "MyObject.h"
class MyClass : public CObject
{
private:
CArray<MyObject*, MyObject*> arrObject; (1)
public:
MyClass();
~MyClass();
void AddObject( MyObject* Object ); (2)
};
////////////////////////////////////////
MyClass.cpp
////////////////////////////////////////
#include "stdafx.h"
#include "myobject.h"
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
void MyClass::AddObject( MyObject* Object ) (3)
{
arrObject.Add( Object );
}
Case One:
------------------------------------------------------------------
If I replace the lines with number for the next lines
CArray<MyObject, MyObject*> arrObject; (1)
void AddObject( MyObject* Object ); (2)
void MyObject::AddObject( MyObject* Object ) (3)
or this
CArray<MyObject, MyObject&> arrObject; (1)
void AddObject( MyObject& Object ); (2)
void MyObject::AddObject( MyObject& Object ) (3)
the code NOT compile, and in both cases the error is:
"MyObject' : 'operator =' function is unavailable
\\vc98\mfc\include\afxtempl.h(1567) : while compiling class-template member function
'void __thiscall CArray<class MyObject,class MyObject *>::SetAtGrow(int,class MyObject *)'"
Case Two:
------------------------------------------------------------------
If I replace the lines with number for the next lines
CArray<MyObject, MyObject> arrObject; (1)
void AddObject( MyObject Object ); (2)
void MyObject::AddObject( MyObject Object ) (3)
the code NOT compile, and the error is:
"No copy constructor available for class 'MyObject'"
even if the copy constructor is added the error is still reported.
////////////////////////////////////////
MyObject.h
////////////////////////////////////////
class MyObject : public CObject
{
public:
MyObject();
~MyObject();
};
////////////////////////////////////////
MyObject.cpp
////////////////////////////////////////
#include "stdafx.h"
#include "myObject.h"
MyObject::MyObject()
{
}
MyObject::~MyObject()
{
}
////////////////////////////////////////
MyClass.h
////////////////////////////////////////
#include <afxtempl.h>
#include "MyObject.h"
class MyClass : public CObject
{
private:
CArray<MyObject*, MyObject*> arrObject; (1)
public:
MyClass();
~MyClass();
void AddObject( MyObject* Object ); (2)
};
////////////////////////////////////////
MyClass.cpp
////////////////////////////////////////
#include "stdafx.h"
#include "myobject.h"
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
void MyClass::AddObject( MyObject* Object ) (3)
{
arrObject.Add( Object );
}
Case One:
------------------------------------------------------------------
If I replace the lines with number for the next lines
CArray<MyObject, MyObject*> arrObject; (1)
void AddObject( MyObject* Object ); (2)
void MyObject::AddObject( MyObject* Object ) (3)
or this
CArray<MyObject, MyObject&> arrObject; (1)
void AddObject( MyObject& Object ); (2)
void MyObject::AddObject( MyObject& Object ) (3)
the code NOT compile, and in both cases the error is:
"MyObject' : 'operator =' function is unavailable
\\vc98\mfc\include\afxtempl.h(1567) : while compiling class-template member function
'void __thiscall CArray<class MyObject,class MyObject *>::SetAtGrow(int,class MyObject *)'"
Case Two:
------------------------------------------------------------------
If I replace the lines with number for the next lines
CArray<MyObject, MyObject> arrObject; (1)
void AddObject( MyObject Object ); (2)
void MyObject::AddObject( MyObject Object ) (3)
the code NOT compile, and the error is:
"No copy constructor available for class 'MyObject'"
even if the copy constructor is added the error is still reported.