[Dev-C++] a trivial question on for loops
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2001-10-17 03:04:21
|
Hello everybody,
I know this is an easy one, but what I've seen on a C++ book puzzled me.
Consider the two pieces of code that follow:
1) as found on a recent C++ book
list<int> l_int;
// ... fill the list with a few intergers
for (list<int>::const_iterator i = l_int.begin(), i != l_int.end(); ++i)
// ... do something
2) as I used to know
list<int> l_int;
// ... fill the list with a few intergers
list<int>::const_iterator stop = l_int.end();
for (list<int>::const_iterator i = l_int.begin(), i != stop; ++i)
// ... do something
The two pieces are equivalent, but the second one is more efficient. Do you
agree with me?
--
gisan
gi...@li...
|