Thread: Vector Functions

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    22

    Question Vector Functions

    I was wondering how to use a vector in a function in the following form.

    batt::additem( vector <int> inv, int id );

    Is that correct or will it raise errors?

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Well, you made a copy of a vector when you probably wanted a reference instead, but it should be fine.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    thanks citizen!

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Learn about iterators, c89c. They are a much better way to pass vectors to functions. And this is especially true when you have a big vector.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed