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

Error C2621

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 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.
  • R Offline
    R Offline
    Reagan Conservative
    wrote on last edited by
    #1

    I cannot understand what the problem is with this code and why I get this error: error C2621: union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor

    struct floatInfoStruct
    {
    float min;
    float max;
    float* result;
    float test;
    };

    struct intInfoStruct
    {
    int min;
    int max;
    int* result;
    int test;
    };

    struct timeInfoStruct
    {
    SECONDS min;
    SECONDS max;
    SECONDS *result;
    TimeFormats Format;
    SECONDS test;
    };

    struct angleInfoStruct
    {
    DEGREES *result;
    DEGREES test;
    };

    struct latlonInfoStruct
    {
    LAT_DEGREES *lat_result;
    LON_DEGREES *lon_result;
    LAT_DEGREES lat_test;
    LON_DEGREES lon_test;
    };

    struct baroInfoStruct
    {
    float min;
    float max;
    float *result;
    float test;
    };

    struct strInfoStruct
    {
    CString min;
    CString max;
    CString *result;
    CString test;
    };

    union EntryInfoUnion
    {
    floatInfoStruct floatInfo;
    intInfoStruct intInfo;
    timeInfoStruct timeInfo;
    angleInfoStruct angleInfo;
    latlonInfoStruct latlonInfo;
    baroInfoStruct baroInfo;
    strInfoStruct strInfo;
    };

    What does the error message (union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor) trying to tell me. I just don't see the problem with the code snippet. Thanks.

    John P.

    D 1 Reply Last reply
    0
    • R Reagan Conservative

      I cannot understand what the problem is with this code and why I get this error: error C2621: union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor

      struct floatInfoStruct
      {
      float min;
      float max;
      float* result;
      float test;
      };

      struct intInfoStruct
      {
      int min;
      int max;
      int* result;
      int test;
      };

      struct timeInfoStruct
      {
      SECONDS min;
      SECONDS max;
      SECONDS *result;
      TimeFormats Format;
      SECONDS test;
      };

      struct angleInfoStruct
      {
      DEGREES *result;
      DEGREES test;
      };

      struct latlonInfoStruct
      {
      LAT_DEGREES *lat_result;
      LON_DEGREES *lon_result;
      LAT_DEGREES lat_test;
      LON_DEGREES lon_test;
      };

      struct baroInfoStruct
      {
      float min;
      float max;
      float *result;
      float test;
      };

      struct strInfoStruct
      {
      CString min;
      CString max;
      CString *result;
      CString test;
      };

      union EntryInfoUnion
      {
      floatInfoStruct floatInfo;
      intInfoStruct intInfo;
      timeInfoStruct timeInfo;
      angleInfoStruct angleInfo;
      latlonInfoStruct latlonInfo;
      baroInfoStruct baroInfo;
      strInfoStruct strInfo;
      };

      What does the error message (union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor) trying to tell me. I just don't see the problem with the code snippet. Thanks.

      John P.

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

      jparken wrote:

      union EntryInfoUnion { ... strInfoStruct strInfo; };

      Union members are not allowed to have (copy) constructors.


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      R D 2 Replies Last reply
      0
      • D David Crow

        jparken wrote:

        union EntryInfoUnion { ... strInfoStruct strInfo; };

        Union members are not allowed to have (copy) constructors.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        R Offline
        R Offline
        Reagan Conservative
        wrote on last edited by
        #3

        David, maybe I can't see the forest for the trees. What is the difference between, say, "floatInfoStruct floatInfo;", and "strInfoStruct strInfo;" being part of the union and causing the 'copy constructor' error? Can you explain this in more detail, please? Thank you.

        John P.

        1 Reply Last reply
        0
        • D David Crow

          jparken wrote:

          union EntryInfoUnion { ... strInfoStruct strInfo; };

          Union members are not allowed to have (copy) constructors.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          D Offline
          D Offline
          Dustin Henry
          wrote on last edited by
          #4

          In other words you can not use a CString in a union since they have copy constructors in them. Try just using a char[] instead.

          R 1 Reply Last reply
          0
          • D Dustin Henry

            In other words you can not use a CString in a union since they have copy constructors in them. Try just using a char[] instead.

            R Offline
            R Offline
            Reagan Conservative
            wrote on last edited by
            #5

            Dustin --- thanks for the response. I just now saw the forest for the trees as you were answering. Sometimes the obvious is too obvious --- like hiding in plain sight. Thanks again.

            John P.

            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