cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
GetUpperBound in vector and array
GetUpperBound in vector and array
Nov 9, 2015 at 5:55am UTC
pawan21
(7)
CArray::GetUpperBound
the upper bound in CArray return upper bound of this array.
there is any api in vector dynamically to get the upper bound.
Nov 9, 2015 at 8:01am UTC
Peter87
(11238)
If you want the index of the last element in the vector you can use
vec.size() - 1
. If you want a reference to the last element in the vector you simply do
vec.back()
. Note that this will only work if the vector is not empty.
http://www.cplusplus.com/reference/vector/vector/size/
http://www.cplusplus.com/reference/vector/vector/back/
Last edited on
Nov 9, 2015 at 8:03am UTC
Topic archived. No new replies allowed.