CMenuItem copy constructor question.

    CMenuItem(const CMenuItem &CM);
  1. Passes CM to CField and Initializes the Label with CM
  2. Sets the _selected to _selected of CM
  3. Sets CFields::_data to the address of _format
  4. Sets the Label’s frame to this object.

CField does not have a copy constructor so is my only way of passing CM to CField something like this?

CMenuItem::CMenuItem(const CMenuItem &CM)
                  :CField(CM._row, CM._col, CM._width, CM._height, 
                             CM.data(), CM.visible(), CM._border), 
                  Label(CM.Label){

}

This this right for step one?

Is there an easier way of doing things?

CM.data() returns a void pointer to the _data of CM so how would I create a new version of whatever is at _data for the deep copy? do I need to? is the pointer just a member and does not actually contain data for CField so deep copy is not needed?

Leave a comment