Results 1 to 9 of 9

Thread: cannot convert 'this' pointer from 'const Square' to 'Square &'

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: cannot convert 'this' pointer from 'const Square' to 'Square &'

    I've solved it changin the line

    Square(rhs.left(),rhs.up(),rhs.right(),rhs.down());
    Square(rhs.data()[left],rhs.data()[UP],rhs.data()[right],rhs.data()[DOWN]);

    But I would want to know why the other line fails.

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: cannot convert 'this' pointer from 'const Square' to 'Square &'

    Are you sure your constructor should not look like this:

    #
    Square(const QPoint &left,const QPoint &up,const QPoint &right,const QPoint &down);
    #

  3. #3
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: cannot convert 'this' pointer from 'const Square' to 'Square &'

    Same result :s

  4. #4
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: cannot convert 'this' pointer from 'const Square' to 'Square &'

    Ok, just realised, this should not work regardless what you do:

    Square::Square(const Square &rhs){
    Square(rhs.left(),rhs.up(),rhs.right(),rhs.down()) ;
    }

    As far as I think to know, you cannot call a constructor within a constructor in C++. This would be JAVA

Similar Threads

  1. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  2. Delegates and Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2006, 19:47
  3. Replies: 10
    Last Post: 10th February 2006, 00:15

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
  •  
Qt is a trademark of The Qt Company.