Results 1 to 4 of 4

Thread: vector iterator as pointer problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Posts
    44
    Qt products
    Qt4 Qt5
    Platforms
    Windows
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: vector iterator as pointer problem

    right it work.

    But many code accept pointer like this


    static void remove(char *NAME){
    Friend *ret = find(NAME);
    if(ret!=NULL){
    vFriend.erase(ret);
    }
    }
    Can i directly convert pointer to iterator?

  2. #2
    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: vector iterator as pointer problem

    Quote Originally Posted by Teerayoot View Post
    But many code accept pointer like this
    But erase takes an iterator not a pointer.


    Qt Code:
    1. static void remove(char *NAME){
    2. Friend *ret = find(NAME);
    3. if(ret!=NULL){
    4. vFriend.erase(ret);
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 
    Depends what vFriend is and what it contains.

    Can i directly convert pointer to iterator?
    Not in this situation. Especially that you don't have any benefit of using a pointer here.

Similar Threads

  1. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  2. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  3. Signals destroys my pointer
    By Jojo in forum Qt Programming
    Replies: 12
    Last Post: 7th March 2006, 21:05
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 15:48

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.