Find your pillow, boring entry inbound...

Published January 23, 2007
Advertisement
Recently I've been working on random stuff, mostly non-graphical, like scripting and now also a difference engine.
However when reading on STL iterators, I found a "bug" in Cprogramming.com s tutorial, as you can see an excerpt from here:
The old approach (avoid) using namespace std;vector<int> myIntVector;// Add some elements to myIntVectormyIntVector.push_back(1);myIntVector.push_back(4);myIntVector.push_back(8);for(int y=0; y{    cout<" "
;
//Should output 1 4 8
}
--------------------------
The STL approach (use this)
using namespace std;

vector<int> myIntVector;
vector<int>::iterator myIntVectorIterator;

// Add some elements to myIntVector
myIntVector.push_back(1);
myIntVector.push_back(4);
myIntVector.push_back(8);

for(myIntVectorIterator = myIntVector.begin();
myIntVectorIterator != myIntVector.end();
myIntVectorIterator++)
{
cout<<*myIntVectorIterator<<" ";
//Should output 1 4 8
}




I looked at this and realised that the first example wont even compile, at least not on my compiler(DevC++), this is because the vectors can only be indexed(or whatever) by an unsigned integer or STL iterator and not by a regular integer. So yeah! They have a bug in their tutorial.

Oh and the difference engine is going good. I'm gonna try and port it to PHP since thats where it's gonna be used: at my friend's site.

I'm gonna install a new network card, I'll see you on the other side [smile].
Previous Entry Untitled
Next Entry Goodbye, Gamedev!
0 likes 2 comments

Comments

Ravuya
I can index STL vectors just fine with a signed integer here, even with -Wall. I'm pretty sure the standard says you can, too.
January 23, 2007 01:41 PM
Samsonite
Hmm, thats strange. Maybe I got some weird configuration going on.
January 24, 2007 08:11 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Goodbye, Gamedev!

1210 views

Untitled

1080 views

Merry Christmas!

1111 views

Untitled

1064 views

Scrolling Demo

1004 views

New PC

883 views

Untitled

826 views

Untitled

857 views

Progress.

885 views
Advertisement