Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
net.cpp AND what on earth is vector<string>::const_ite
06-05-2006, 05:41 PM,
#2
 
I am pretty unfamiliar with the network code, but when I search through net.cpp and net.h I don't see the line you're referring to in the code block.

What you see there is an iterator for a vector of strings. A vector<string> is like an array of strings, but a vector's a little more flexible than an array. An iterator is just a generic interface for looking at objects from a collection in order. So it makes sense to get the next string in the vector by doing ++i and to dereference the iterator to the string itself with *i. So if you have a vector that looks like this

["blah", "bleh", "bluh", "aaargh"]

and you do something like
Code:
vector<string> blah_string;
/* put the above values into blah_string*/
vector<string>::const_iterator i;
for( i = blah_string.begin(); i != blah_string.end(); ++i ) {
    cout << *i << endl;
}
it will print the values in order with each on a line.
Reply


Messages In This Thread
[No subject] - by thelusiv - 06-05-2006, 05:41 PM
[No subject] - by joevenzon_phpbb2_import3 - 06-05-2006, 09:44 PM
[No subject] - by thelusiv - 06-06-2006, 12:36 AM
[No subject] - by nael - 06-06-2006, 09:41 AM
[No subject] - by thelusiv - 06-06-2006, 12:49 PM
[No subject] - by joevenzon_phpbb2_import3 - 06-06-2006, 08:02 PM
[No subject] - by nael - 06-07-2006, 01:51 PM
[No subject] - by joevenzon_phpbb2_import3 - 06-07-2006, 08:52 PM
[No subject] - by matthew_i - 06-11-2006, 03:12 PM
[No subject] - by nael - 06-12-2006, 09:30 AM
[No subject] - by joevenzon_phpbb2_import3 - 06-12-2006, 08:09 PM
[No subject] - by nael - 06-13-2006, 10:59 AM
[No subject] - by thelusiv - 06-13-2006, 02:02 PM
[No subject] - by nael - 06-14-2006, 01:21 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)