|
-
February 5th, 2008, 05:12 PM
#1
vectors!
how do we access vector indexes for instance 0,1,2,3 without using addresses and references?
-
February 5th, 2008, 05:21 PM
#2
Re: vectors!
Like this?
Code:
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
int i = vec[1];
- petter
-
February 5th, 2008, 07:36 PM
#3
Re: vectors!
Or maybe using an iterator??
Code:
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
std::vector<int>::iterator it = vec.begin();
int i = *it;
int j = *(it++);
Mike
-
February 6th, 2008, 12:25 AM
#4
Re: vectors!
Code:
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
int i = vec.at(0);
int j = vec.at(1);
?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|