Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. C++ struct function with return struct ...
Forum Updated to NodeBB v4.3 + New Features

C++ struct function with return struct ...

Scheduled Pinned Locked Moved Solved C++ Gurus
22 Posts 5 Posters 10.9k 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.
  • G gfxx
    28 Sept 2016, 20:46

    @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
    Giorgio

    V Offline
    V Offline
    VRonin
    wrote on 29 Sept 2016, 07:16 last edited by VRonin
    #21

    @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)

    http://www.geeksforgeeks.org/g-fact-76/

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    G 1 Reply Last reply 29 Sept 2016, 09:05
    2
    • V VRonin
      29 Sept 2016, 07:16

      @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)

      http://www.geeksforgeeks.org/g-fact-76/

      G Offline
      G Offline
      gfxx
      wrote on 29 Sept 2016, 09:05 last edited by gfxx
      #22

      @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

      bkt

      1 Reply Last reply
      0

      21/22

      29 Sept 2016, 07:16

      • Login

      • Login or register to search.
      21 out of 22
      • First post
        21/22
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved