Results 1 to 2 of 2

Thread: about no matching function for call to

  1. #1
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    1

    Default about no matching function for call to

    I am working on an old program. When I use old gcc version to compile the program, it works well, but when I use new gcc version, the program doesn't work. the program is as follows, and the error is "no matching function for call to divide(Vector3D,Vector3D&)".
    Qt Code:
    1. struct Vector3D {
    2. double x, y, z;
    3.  
    4. Vector3D () {}
    5. Vector3D (double x, double y, double z) {
    6. this->x = x; this->y = y; this->z = z;
    7. }
    8. Vector3D (const SmallVector3D& v);
    9. ...........
    10. friend Vector3D divide (const Vector3D& p1, const Vector3D& p2) {
    11. return Vector3D (p1.x / p2.x, p1.y / p2.y, p1.z / p2.z);
    12. }
    13.  
    14. class BucketTable3D {
    15. protected:
    16. int _nGrids [ 3 ];
    17. Vector3D _min, _max;
    18. Vector3D _gridWidth;
    19. public:
    20. int* nGrids() { return _nGrids; }
    21. virtual void indicesAt ( const Vector3D& position, int& x, int& y, int& z )
    22. {
    23.  
    24. Vector3D n = ::divide ( position - _min, _gridWidth );
    25. x = (int) n.x; y = (int) n.y; z = (int) n.z;
    26. ........
    27. }
    To copy to clipboard, switch view to plain text mode 
    Thanks for your kindly help!
    Alain
    Last edited by Lykurg; 3rd March 2011 at 05:11. Reason: missing [code] tags

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: about no matching function for call to

    If this divide is declared inside Vector3D class, then it makes no sense - x,y,z are public, so every method can access those variables without having to be declared as "friend". To fix this, you can for example mark this method as "static" inside Vector3D class and call it like this:
    Qt Code:
    1. Vector3D n = Vector3D::divide ( position - _min, _gridWidth );
    To copy to clipboard, switch view to plain text mode 
    Or simply move this method outside Vector3D class (this way you can keep the old calls).

Similar Threads

  1. Replies: 1
    Last Post: 1st December 2010, 11:02
  2. no matching function for call to setupUi
    By ctote in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2010, 15:20
  3. no matching function error
    By arpspatel in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2009, 15:47
  4. Replies: 7
    Last Post: 16th August 2009, 09:03
  5. No Matching function to call...
    By weepdoo in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 17:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.