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. why I can't declaring a CArray object in a separate header file [modified]

why I can't declaring a CArray object in a separate header file [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncsharpvisual-studio
11 Posts 2 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.
  • E Electronic75

    Hello :) I have no problem declaring a CArray variable inside a class definition but as I have a separate file that I place all my typedefs inside it have tried to define a struct that has a CArray member but compiler says: Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272 this was my code inside TypeDefs.H typedef struct tag_compliance_info { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CArray<POINT> aCompliance; //Oh I forgot this board filters <> signs } STRUCT_COMPLIANCE_INFO; How can I solve this?

    modified on Friday, October 24, 2008 3:12 AM

    K Offline
    K Offline
    KarstenK
    wrote on last edited by
    #2

    use a Poiner CArray * or another object to substitute the CArray. is it really essential?

    Greetings from Germany

    E 1 Reply Last reply
    0
    • K KarstenK

      use a Poiner CArray * or another object to substitute the CArray. is it really essential?

      Greetings from Germany

      E Offline
      E Offline
      Electronic75
      wrote on last edited by
      #3

      Hi KarstenK :) , You mean there is no way? but why? there should be a reason. what other objects you mean? Thanks

      K 1 Reply Last reply
      0
      • E Electronic75

        Hi KarstenK :) , You mean there is no way? but why? there should be a reason. what other objects you mean? Thanks

        K Offline
        K Offline
        KarstenK
        wrote on last edited by
        #4

        You got me wrong. :~ I think the constructor of the CArray dont like it that way. Do you really need the CArray? What will be in it?

        Greetings from Germany

        E 1 Reply Last reply
        0
        • K KarstenK

          You got me wrong. :~ I think the constructor of the CArray dont like it that way. Do you really need the CArray? What will be in it?

          Greetings from Germany

          E Offline
          E Offline
          Electronic75
          wrote on last edited by
          #5

          I'm not sure I still clear but do you mean CArray constructor has written in away that can't be declared in a struct and other objects do not have this problem. I want to store an array of 2 long int so either CArray<LONG,LONG>aMyarray or CArray<POINT>aMyArray Danke:rose:

          K 1 Reply Last reply
          0
          • E Electronic75

            I'm not sure I still clear but do you mean CArray constructor has written in away that can't be declared in a struct and other objects do not have this problem. I want to store an array of 2 long int so either CArray<LONG,LONG>aMyarray or CArray<POINT>aMyArray Danke:rose:

            K Offline
            K Offline
            KarstenK
            wrote on last edited by
            #6

            Some constructors of the CArray aren't public (with good reason). or try typedef CArray<long,> CMyArray; struct { CMyArray m_array; }

            Greetings from Germany

            E 1 Reply Last reply
            0
            • K KarstenK

              Some constructors of the CArray aren't public (with good reason). or try typedef CArray<long,> CMyArray; struct { CMyArray m_array; }

              Greetings from Germany

              E Offline
              E Offline
              Electronic75
              wrote on last edited by
              #7

              dose not work. I even tried to inherit my struct from CObject but since the problem is accessing private members not protected couldn't solve the problem! typedef struct tag_compliance_info: CObject { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CArray<POINT> aCompliance; } STRUCT_COMPLIANCE_INFO;

              K 1 Reply Last reply
              0
              • E Electronic75

                dose not work. I even tried to inherit my struct from CObject but since the problem is accessing private members not protected couldn't solve the problem! typedef struct tag_compliance_info: CObject { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CArray<POINT> aCompliance; } STRUCT_COMPLIANCE_INFO;

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #8

                why havent you tried it like i posted it you? :~ And you NEED a Array because the is a lot and different count of points:confused:

                Greetings from Germany

                E 1 Reply Last reply
                0
                • K KarstenK

                  why havent you tried it like i posted it you? :~ And you NEED a Array because the is a lot and different count of points:confused:

                  Greetings from Germany

                  E Offline
                  E Offline
                  Electronic75
                  wrote on last edited by
                  #9

                  KarstenK wrote:

                  why havent you tried it like i posted it you? Unsure

                  Hello :) I did but as I said it dose not work. you typed ypedef CArray<long,> CMyArray; struct { CMyArray m_array; } but I think there are many typos in it so I typed typedef CArray<POINT> CMyArray; typedef struct tag_compliance_info { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CMyArray aCompliance; } STRUCT_COMPLIANCE_INFO; still I get Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272

                  KarstenK wrote:

                  And you NEED a Array because the is a lot and different count of pointsConfused

                  Exactly :)

                  K 1 Reply Last reply
                  0
                  • E Electronic75

                    KarstenK wrote:

                    why havent you tried it like i posted it you? Unsure

                    Hello :) I did but as I said it dose not work. you typed ypedef CArray<long,> CMyArray; struct { CMyArray m_array; } but I think there are many typos in it so I typed typedef CArray<POINT> CMyArray; typedef struct tag_compliance_info { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CMyArray aCompliance; } STRUCT_COMPLIANCE_INFO; still I get Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272

                    KarstenK wrote:

                    And you NEED a Array because the is a lot and different count of pointsConfused

                    Exactly :)

                    K Offline
                    K Offline
                    KarstenK
                    wrote on last edited by
                    #10

                    in VS2008 i could compile and link::cool: typedef CArray CMyArray; typedef struct tag_compliance_info { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CMyArray aCompliance; } STRUCT_COMPLIANCE_INFO; or must use a pointer CMyArray* paCompliance;

                    Greetings from Germany

                    E 1 Reply Last reply
                    0
                    • K KarstenK

                      in VS2008 i could compile and link::cool: typedef CArray CMyArray; typedef struct tag_compliance_info { LONG lModuleCode; LONG lModuleVersion; CString sModuleName; CMyArray aCompliance; } STRUCT_COMPLIANCE_INFO; or must use a pointer CMyArray* paCompliance;

                      Greetings from Germany

                      E Offline
                      E Offline
                      Electronic75
                      wrote on last edited by
                      #11

                      Well I use visual studio 2005 :(( danke anyway

                      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