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. Managed C++/CLI
  4. do get_ and set_ have to be used in conjunction?

do get_ and set_ have to be used in conjunction?

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++visual-studiohelpquestion
3 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.
  • C Offline
    C Offline
    charlener
    wrote on last edited by
    #1

    In my header file, I'm using only get_dataSectionPtr and no set (its value is set in the constructor) and I get the following errors: c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' AbfFileStruct.cpp(12) : error C2039: 'set_dataSectionPtr' : is not a member of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(15) : see declaration of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' And the offending code seems to be this: public __gc class AbfFileStruct { public: //always need at least a FileStream to construct it AbfFileStruct(FileStream *); __property long get_dataSectionPtr() { return dataSectionPtr; } void PrintFileStruct(); private: long dataSectionPtr; }; //ENDCLASS Ideas?

    C A 2 Replies Last reply
    0
    • C charlener

      In my header file, I'm using only get_dataSectionPtr and no set (its value is set in the constructor) and I get the following errors: c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' AbfFileStruct.cpp(12) : error C2039: 'set_dataSectionPtr' : is not a member of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(15) : see declaration of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' And the offending code seems to be this: public __gc class AbfFileStruct { public: //always need at least a FileStream to construct it AbfFileStruct(FileStream *); __property long get_dataSectionPtr() { return dataSectionPtr; } void PrintFileStruct(); private: long dataSectionPtr; }; //ENDCLASS Ideas?

      C Offline
      C Offline
      charlener
      wrote on last edited by
      #2

      Oh, and there's another header file (AbfFileInfo.h) that has the get_ properties and doesn't give any errors...

      1 Reply Last reply
      0
      • C charlener

        In my header file, I'm using only get_dataSectionPtr and no set (its value is set in the constructor) and I get the following errors: c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' AbfFileStruct.cpp(12) : error C2039: 'set_dataSectionPtr' : is not a member of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(15) : see declaration of 'AbfFileStruct' c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(43) : error C2086: 'long AbfFileStruct::dataSectionPtr' : redefinition c:\Documents and Settings\administrator\My Documents\Visual Studio Projects\byteme\AbfFileStruct.h(21) : see declaration of 'AbfFileStruct::dataSectionPtr' And the offending code seems to be this: public __gc class AbfFileStruct { public: //always need at least a FileStream to construct it AbfFileStruct(FileStream *); __property long get_dataSectionPtr() { return dataSectionPtr; } void PrintFileStruct(); private: long dataSectionPtr; }; //ENDCLASS Ideas?

        A Offline
        A Offline
        Andy Wieberneit
        wrote on last edited by
        #3

        The reason for this error is that your private member variable (dataSectionPtr) has the same name as your property. That's because from your get_ method, the compiler will generate a property dataSectionPtr. Just rename your private member variable, and your code will compile.

        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