copy derived structure, is it legal c++ code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FFMG

    copy derived structure, is it legal c++ code?

    Hi,

    I am trying to copy some variables from a struct to a derived struct.
    If I have something like,

    ....
    struct STRUCTA
    {
    int numA;
    long numB;
    float numC;
    }

    struct STRUCTB public STRUCTA
    {
    int numD;
    }
    ....

    STRUCTA structA = {0,1,2};
    STRUCTB structB;
    memcpy( &structB, &structA, sizeof( STRUCTA) );

    ....
    //
    Is the above code legal to copy the structure from structA to structB

    Thanks

    F.
Working...