Home > Software engineering >  VS2008 project, because the structure byte string caused by the problems of the assignment collapse,
VS2008 project, because the structure byte string caused by the problems of the assignment collapse,

Time:09-19



Without manual bytes to its, sizeof (struct)=77, under the condition of the manual for the assignment does not collapse, strives for the bosses to solve!

CodePudding user response:

# pragma pack structure specified byte alignment try
 
# pragma pack (push, 8)
Typedef struct _tagxxxx_t
{
} XXXX.
# pragma pack (pop)


CodePudding user response:

# pragma pack I tried doesn't crash, structure variable position adjustment will not collapse, I just want to know why the string assignment will collapse

CodePudding user response:

Structure definition will not collapse in the format
Int iLine;
Int iCorner;
Int total_layer;
Float pixel_to_mm;
Float min_length;
Float max_length;
Float max_angle_thresh;

Bool isDrawBarcode;//is in the draw bar code on the picture

Bool isDrawLine;
Bool isShowData;
Bool isShowAngle;
Bool isDetectAngle: 2;

CV: : the Rect detected_rect;
STD: : string strBarcode;

CodePudding user response:

This structure should write a deep copy construction and overloaded assignment operator

CodePudding user response:

Have to write the assignment operator, this is a whole structure of code

Typedef struct stInputParams
{
Int iLine;
Int iCorner;
Int total_layer;
Float pixel_to_mm;
Float min_length;
Float max_length;
Float max_angle_thresh;

Bool isDrawBarcode;//is in the draw bar code on the picture

Bool isDrawLine;
Bool isShowData;
Bool isShowAngle;
Bool isDetectAngle;

CV: : the Rect detected_rect;
STD: : string strBarcode;

StInputParams ()
{
ILine=1;
ICorner=1;
Total_layer=5;
Pixel_to_mm=0.01 f;
Min_length=0.1;
Max_length=1.4 f;
Max_angle_thresh=90.0 f;

IsDrawBarcode=false;

IsDrawLine=true;
IsShowData=https://bbs.csdn.net/topics/true;
IsDetectAngle=true;
IsShowAngle=true;
Detected_rect=CV: : the Rect (0, 0, 0, 0);
StrBarcode=STD: : string (" ERROR ");
}

StInputParams operator=(const stInputParams& Params)
{
ILine=params. ILine;
ICorner=params. ICorner;
Total_layer=params. Total_layer;
Pixel_to_mm=params. Pixel_to_mm;
Min_length=params. Min_length;
Max_length=params. Max_length;
Max_angle_thresh=params. Max_angle_thresh;

IsDrawBarcode=params. IsDrawBarcode;

IsDrawLine=params. IsDrawLine;
IsShowData=https://bbs.csdn.net/topics/params.isShowData;
IsDetectAngle=params. IsDetectAngle;
IsShowAngle=params. IsShowAngle;
Detected_rect=params. Detected_rect;
StrBarcode=params. StrBarcode;

Return (* this);
}

} stInputParams;

CodePudding user response:

reference 5 floor lhw330472787 reply:
already has written assignment operator, this is a whole structure of code

Typedef struct stInputParams
{
Int iLine;
Int iCorner;
Int total_layer;
Float pixel_to_mm;
Float min_length;
Float max_length;
Float max_angle_thresh;

Bool isDrawBarcode;//is in the draw bar code on the picture

Bool isDrawLine;
Bool isShowData;
Bool isShowAngle;
Bool isDetectAngle;

CV: : the Rect detected_rect;
STD: : string strBarcode;

StInputParams ()
{
ILine=1;
ICorner=1;
Total_layer=5;
Pixel_to_mm=0.01 f;
Min_length=0.1;
Max_length=1.4 f;
Max_angle_thresh=90.0 f;

IsDrawBarcode=false;

IsDrawLine=true;
IsShowData=https://bbs.csdn.net/topics/true;
IsDetectAngle=true;
IsShowAngle=true;
Detected_rect=CV: : the Rect (0, 0, 0, 0);
StrBarcode=STD: : string (" ERROR ");
}

StInputParams operator=(const stInputParams& Params)
{
ILine=params. ILine;
ICorner=params. ICorner;
Total_layer=params. Total_layer;
Pixel_to_mm=params. Pixel_to_mm;
Min_length=params. Min_length;
Max_length=params. Max_length;
Max_angle_thresh=params. Max_angle_thresh;

IsDrawBarcode=params. IsDrawBarcode;

IsDrawLine=params. IsDrawLine;
IsShowData=https://bbs.csdn.net/topics/params.isShowData;
IsDetectAngle=params. IsDetectAngle;
IsShowAngle=params. IsShowAngle;
Detected_rect=params. Detected_rect;
StrBarcode=params. StrBarcode;

Return (* this);
}

} stInputParams;

Separate test this no problem, if other places caused by the operation of crossing the line and/or information has been modified?


  • Related