Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. compiler generated function

compiler generated function

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++helpquestion
16 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S sheetal_06

    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..

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #7

    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

    P 1 Reply Last reply
    0
    • D David Crow

      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

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #8

      Probably, he is showing the declaration in header. Atleast I assumed it, while giving replies.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      1 Reply Last reply
      0
      • S sheetal_06

        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..

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #9

        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?

        S 1 Reply Last reply
        0
        • M Mark Salsbery

          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?

          S Offline
          S Offline
          sheetal_06
          wrote on last edited by
          #10

          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???

          M 1 Reply Last reply
          0
          • S sheetal_06

            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???

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #11

            Something else is wrong then... CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; These are not CPtrArrays!

            S 1 Reply Last reply
            0
            • M Mark Salsbery

              Something else is wrong then... CSpanLoad *pA3Ld,*pBDLd; *pA3Ld = *pBDLd; These are not CPtrArrays!

              S Offline
              S Offline
              sheetal_06
              wrote on last edited by
              #12

              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; }

              M 1 Reply Last reply
              0
              • S sheetal_06

                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; }

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #13

                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.

                S 1 Reply Last reply
                0
                • M Mark Salsbery

                  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.

                  S Offline
                  S Offline
                  sheetal_06
                  wrote on last edited by
                  #14

                  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..

                  M 1 Reply Last reply
                  0
                  • S sheetal_06

                    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..

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #15

                    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.

                    S 1 Reply Last reply
                    0
                    • M Mark Salsbery

                      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.

                      S Offline
                      S Offline
                      sheetal_06
                      wrote on last edited by
                      #16

                      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 & { //.... }

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups