-
@VRonin yes struct and class is quite similar .... but not the same things..... I know .. some C programmers not like class and prefer struct .... When I was A good programmer I use me too only struct and no class .... but for now I'm happy class exist .... ;)
regards
Giorgiowrote on 29 Sept 2016, 07:16 last edited by VRonin@gfxx C has no classes. C has only structs and they cannot contain methods, just members. C is not an object oriented language. In C++ they are the same, the only difference is the default access level (public for struct, private for class)
-
@gfxx C has no classes. C has only structs and they cannot contain methods, just members. C is not an object oriented language. In C++ they are the same, the only difference is the default access level (public for struct, private for class)
wrote on 29 Sept 2016, 09:05 last edited by gfxx@VRonin I Know that C has no classes .. I use it sometime, but I study it only 10 year ago and not use it for long long time ...... but I also know that many good programmers using C ++ but most use C do not really like the classes especially if you can use the struct .... but unfortunately I'm not a good programmer ... so use the classes and I facilitate my work .... anyway thanks to this link so today I can learn something new. :))
anyhow I'm not a good programmer and if you would suggest me some modification to my code example, in order to make me able to use struct instead class I'm happy to receive your suggest.
Some post ago I write these snip:
/***********MYQThread .h*****************/ struct FindACPTarghet{ cv::Point2f Square_Points[4]; bool Find_Upper_Half_Square; bool Find_Lower_Half_Square; cv::Point Get_centrale; cv::Point Get_mezzo_rect_risc; cv::Point Get_mezzo_rect_risc1; cv::Point Get_mezzo_rect_risc_pt2; cv::Point Get_mezzo_rect_risc_pt3; double X_Point; double Y_point; double Angle; bool Major_Side1; bool Major_Side2; bool Get_Upper_Half_Square; bool Get_Lower_Half_Square; //Get_Angle_Central_Point_Targhet GetDataTarghet; }/*FindCentPoint*/; class datathread : public QThread { Q_OBJECT public: explicit datathread(QObject *parent = 0, bool bthw = false); void run(); bool Stop; FindACPTarghet FindCentPoint( cv::Point2f Square_Points[4], bool Find_Upper_Half_Square, bool Find_Lower_Half_Square); /***********MYQThread .cpp*****************/ FindACPTarghet FindCentPoint( cv::Point2f Square_Points[4], bool Find_Upper_Half_Square, bool Find_Lower_Half_Square) { FindACPTarghet FindTarghet; <---------------------------------------- F_lung1 = 0; F_lung2 = 0; F_lung3 = 0; F_lung4 = 0; F_lung5 = 0; F_barix = 0; F_bariy = 0; F_intbarix = 0; F_intbariy = 0; F_bariangle = 0; bool choose0 = false, choose1 = false, choose2 = false, choose3 = false; F_lung1 = std::pow((std::pow((Square_Points[0].x - Square_Points[1].x),2) + std::pow((Square_Points[0].y - Square_Points[1].y),2)), 0.5); F_lung2 = std::pow((std::pow((Square_Points[1].x - Square_Points[2].x),2) + std::pow((Square_Points[1].y - Square_Points[2].y),2)), 0.5); if (F_lung2 > F_lung1) {.................. ........................ FindTarghet.Get_centrale = F_centrale; <--------------------------------- /*******************************undefined error reference**********************/ FindTarghet.Get_mezzo_rect_risc = F_mezzo_rect_risc; FindTarghet.Get_mezzo_rect_risc1 = F_mezzo_rect_risc1; FindTarghet.Get_mezzo_rect_risc_pt2 = F_mezzo_rect_risc_pt2; FindTarghet.Get_mezzo_rect_risc_pt3 = F_mezzo_rect_risc_pt3; FindTarghet.X_Point = F_intbarix; FindTarghet.Y_point = F_intbariy; FindTarghet.Angle = F_bariangle_template; FindTarghet.Major_Side1 = false; FindTarghet.Major_Side2 = false; FindTarghet.Get_Upper_Half_Square = false; FindTarghet.Get_Lower_Half_Square = false; return FindTarghet; } /***********MYQThread .cpp qthread::run*****************/ void datathread::run() { ... ... ... FindACPTarghet OneTarghet = FindCentPoint(rect_points, true, false); centrale = OneTarghet.Get_centrale; mezzo_rect_risc = OneTarghet.Get_mezzo_rect_risc; mezzo_rect_risc1 = OneTarghet.Get_mezzo_rect_risc1; mezzo_rect_risc_pt2 = OneTarghet.Get_mezzo_rect_risc_pt2; mezzo_rect_risc_pt3 = OneTarghet.Get_mezzo_rect_risc_pt3; intbarix = OneTarghet.X_Point; intbariy = OneTarghet.Y_point; bariangle = OneTarghet.Angle;
Not work ... but compile is ok...
Thank a lot
Giorgio
21/22