Results 1 to 16 of 16

Thread: strange problem passing a vector

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: strange problem passing a vector

    I think that if you have a method that returns void, passing a reference to a pointer to return something from the method doesn't make much sense - it's better to use a more... traditional approach. But in the above situation it doesn't make sense to pass a reference to a pointer.

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    37
    Thanked 53 Times in 40 Posts

    Default Re: strange problem passing a vector

    Quote Originally Posted by wysota View Post
    I think that if you have a method that returns void, passing a reference to a pointer to return something from the method doesn't make much sense - it's better to use a more... traditional approach. But in the above situation it doesn't make sense to pass a reference to a pointer.
    Yes, but may be you can use them in helper functions like this.. It saves function calls as well as neatly modularizes the code. Ofcourse it is not conventional.

    void createResources(int *&handle, SomeResource *&s, Pen *& pen)
    {
    }
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: strange problem passing a vector

    Yes, maybe... But I wouldn't. Try maintaining such code... Besides, in most cases you'd pass a reference to an object, not to its pointer.

Similar Threads

  1. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 10:26
  2. Strange problem with events on Unix
    By sukanyarn in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 02:45
  3. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 10:36

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.