compiler generated function
-
When i am compiling the following code i am getting an error. ERROR is: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' Why the compiler is generating the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'? CPtrArray inherits CObject but it does not implement operator= This error message is coming after conversion to .net.. class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){} }; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS2005.In VC6 it was not showing the error; } Thanks..
sheetal_06 wrote:
void operator=( const CCASObject& );
How this operator is defined? How you are using
aPointArrays
in your code ?Prasad Notifier using ATL | Operator new[],delete[][^]
-
sheetal_06 wrote:
void operator=( const CCASObject& );
How this operator is defined? How you are using
aPointArrays
in your code ?Prasad Notifier using ATL | Operator new[],delete[][^]
Hi, It is getting invoked when *pA3Ld = *pBDLd; is executed.And there only it is giving error. //this is how it is used... // adding CPtrArray *pPoints = new CPtrArray; aPointArrays.Add( pPoints ); // Delete any CPoints stored for undrawing int iTot = aPointArrays.GetSize(); int iCur; for( iCur = 0; iCur < iTot; iCur++ ) { CPtrArray *pPoints = (CPtrArray*)aPointArrays.GetAt( iCur ); int iTot2 = pPoints->GetSize(); --- --- } Thanks
-
When i am compiling the following code i am getting an error. ERROR is: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' Why the compiler is generating the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'? CPtrArray inherits CObject but it does not implement operator= This error message is coming after conversion to .net.. class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){} }; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS2005.In VC6 it was not showing the error; } Thanks..
sheetal_06 wrote:
class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... }
Here you have mistaken with assignment operator. It should be like this,
class CSpanLoad : public CCASObject
{
public:
void operator=( const CCASObjectCSpanLoad& );private:
CPtrArray aPointArrays;
};//spanload.cpp
void CSpanLoad::operator=( const CCASObjectCSpanLoad& src )
{//....
}Prasad Notifier using ATL | Operator new[],delete[][^]
-
sheetal_06 wrote:
class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... }
Here you have mistaken with assignment operator. It should be like this,
class CSpanLoad : public CCASObject
{
public:
void operator=( const CCASObjectCSpanLoad& );private:
CPtrArray aPointArrays;
};//spanload.cpp
void CSpanLoad::operator=( const CCASObjectCSpanLoad& src )
{//....
}Prasad Notifier using ATL | Operator new[],delete[][^]
but it was working in VC6(before converting to .net..) Thanks
-
but it was working in VC6(before converting to .net..) Thanks
sheetal_06 wrote:
(before converting to .net..)
To start with , its not
.net
, itsVS 2008,VC8
. There is lot of difference betn VC 6 and VC 8. As far as C++ standards are concerned, earlier version of VS was far behind. Which has been corrected with VS2K3 and VS2k5. Giving error in this case, in fact it is sticking to C++ rules.Prasad Notifier using ATL | Operator new[],delete[][^]
-
When i am compiling the following code i am getting an error. ERROR is: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' Why the compiler is generating the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'? CPtrArray inherits CObject but it does not implement operator= This error message is coming after conversion to .net.. class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){} }; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS2005.In VC6 it was not showing the error; } Thanks..
sheetal_06 wrote:
class CPtrArray : public CObject { //does not implement operator= }
I'm curious how you got this to compile in VC++ v6 since
CPtrArray
is an existing MFC class, and the class is missing a semicolon. :confused:
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
sheetal_06 wrote:
class CPtrArray : public CObject { //does not implement operator= }
I'm curious how you got this to compile in VC++ v6 since
CPtrArray
is an existing MFC class, and the class is missing a semicolon. :confused:
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Probably, he is showing the declaration in header. Atleast I assumed it, while giving replies.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
When i am compiling the following code i am getting an error. ERROR is: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' Why the compiler is generating the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'? CPtrArray inherits CObject but it does not implement operator= This error message is coming after conversion to .net.. class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){} }; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS2005.In VC6 it was not showing the error; } Thanks..
I've answered this several times for you. You HAVE to have an assignment operator for CObject derived classes if they are to be used in a container. Why not just implement the operator in your class?
-
I've answered this several times for you. You HAVE to have an assignment operator for CObject derived classes if they are to be used in a container. Why not just implement the operator in your class?
I have implemented operator= in CCasObject and in CSpanLoad.But operator= is not there in CPtrArray which is an MFC class..How can i add operator= into CPtrArray???
-
I have implemented operator= in CCasObject and in CSpanLoad.But operator= is not there in CPtrArray which is an MFC class..How can i add operator= into CPtrArray???
Something else is wrong then... CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; These are not CPtrArrays!
-
Something else is wrong then... CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; These are not CPtrArrays!
CPtrArray is a member of CSpanLoad... class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){}}; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS8.In VC6 it was not showing the error; }
-
CPtrArray is a member of CSpanLoad... class CPtrArray : public CObject { //does not implement operator= } class __declspec ( dllexport ) CCASObject : public CObject { public: virtual void operator=( const CCADSObject& ){}}; class CSpanLoad : public CCASObject { public: void operator=( const CCASObject& ); private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CCASObject &src ) { //.... } //Import.cpp int CImport::ReadLoadCategoryData() { CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; //this assignment is giving error in VS8.In VC6 it was not showing the error; }
Ohhh now we're getting close! :) You'll need to implement the copy from one array to another. Deep copy would be creating a new pointer of the object type of the pointer. A shallow copy would be just copying the pointers from the source to the destination array. Just PtrArray = Src.PtrArray; won't work.
-
Ohhh now we're getting close! :) You'll need to implement the copy from one array to another. Deep copy would be creating a new pointer of the object type of the pointer. A shallow copy would be just copying the pointers from the source to the destination array. Just PtrArray = Src.PtrArray; won't work.
could u plz tell me so where is the actual problem??I thought it is generating the error: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' b'coz i am trying to pass a CSpanload object into a CCasObject.CCasObject is a dll.So while compiling it may do static linking.At that time it is trying to locate the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' which is not actually implemented in CPtrArray...If i am wrong plz correct..
-
could u plz tell me so where is the actual problem??I thought it is generating the error: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'" see declaration of 'CObject::operator =' see declaration of 'CObject' This diagnostic occurred in the compiler generated function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' b'coz i am trying to pass a CSpanload object into a CCasObject.CCasObject is a dll.So while compiling it may do static linking.At that time it is trying to locate the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)' which is not actually implemented in CPtrArray...If i am wrong plz correct..
sheetal_06 wrote:
At that time it is trying to locate the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'
There isn't one implemented. That's why it's an error.
sheetal_06 wrote:
i am trying to pass a CSpanload object into a CCasObject
How are you passing it? Are you sure you need to do a full copy or could you pass a reference or pointer? If you must copy then you'll need to copy the CPtrArray member appropriately. Since it's an array of pointers - if the pointers are allocated using new and you copy the pointers from one array to another, then delete the pointers in one array and try to delete the pointers again in the copy array then it will crash.
-
sheetal_06 wrote:
At that time it is trying to locate the function 'CPtrArray &CPtrArray::operator =(const CPtrArray &)'
There isn't one implemented. That's why it's an error.
sheetal_06 wrote:
i am trying to pass a CSpanload object into a CCasObject
How are you passing it? Are you sure you need to do a full copy or could you pass a reference or pointer? If you must copy then you'll need to copy the CPtrArray member appropriately. Since it's an array of pointers - if the pointers are allocated using new and you copy the pointers from one array to another, then delete the pointers in one array and try to delete the pointers again in the copy array then it will crash.
Ya,I need to copy the pointer.. The pointers *pA3Ld and *pBDLd are created using new... So could u plz suggest one solution... When i am changing the code as follows it is working...But i din understand why? class CSpanLoad : public CCASObject { public: void operator=( const CSpanLoad & );//earlier it was const CCASObject & private: CPtrArray aPointArrays; }; //spanload.cpp void CSpanLoad::operator=( const CSpanLoad &src )//earlier it was const CCASObject & { //.... }