Results 1 to 2 of 2

Thread: vector

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default vector

    Hi, I've a public vector inside a class; I'd like code a function that return this vector;
    like ah: obj.getVectorLight().begin(); I'd like make this vector private...
    Qt Code:
    1. std::vector<Light> light;
    2. std::vector<Light> getLight_vector();
    To copy to clipboard, switch view to plain text mode 
    How to write this function?
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: vector

    Quote Originally Posted by mickey
    std::vector<Light> getLight_vector();
    This method will return a copy of that vector --- you have to return a reference:
    Qt Code:
    1. std::vector<Light>& getLight_vector() { return light; }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Map as return Type
    By Kapil in forum General Programming
    Replies: 8
    Last Post: 25th May 2006, 21:49
  2. <vector> and new
    By mickey in forum General Programming
    Replies: 11
    Last Post: 18th May 2006, 16:27
  3. vector of objects
    By mickey in forum General Programming
    Replies: 2
    Last Post: 8th May 2006, 21:13
  4. vector
    By mickey in forum General Programming
    Replies: 12
    Last Post: 28th April 2006, 11:49
  5. vector memory allocation
    By TheKedge in forum General Programming
    Replies: 1
    Last Post: 23rd March 2006, 18:27

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.