When I pass vector to a function by address (vector &A) ,will I be able to use all the stl functions like lower_bound ,upper_bound on A . If yes , how to use them ?
Asked
Active
Viewed 153 times
-6
-
8`vector &A` is passing by reference, not by address, usage of standard functions is absolutely the same as with ordinary variable – Iłya Bursov Jan 14 '19 at 17:19
-
2I feel that this is a dup. https://stackoverflow.com/questions/57483/what-are-the-differences-between-a-pointer-variable-and-a-reference-variable-in – UKMonkey Jan 14 '19 at 17:27
-
1Welcome to Stack Overflow! Sounds like you could use a [good C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver Jan 14 '19 at 17:33
-
Yes, and you use them [as normal](https://en.cppreference.com/w/cpp/algorithm). They're all documented - read the docs, and ask another question if you try something and encounter a problem you can't figure out. – Useless Jan 14 '19 at 17:34
1 Answers
-1
You're passing a reference, not "by address".
Within the function, the name A
refers to the vector, just like its original name did.
You can do everything with it, like normal.
Try it and see.

Lightness Races in Orbit
- 378,754
- 76
- 643
- 1,055