i've not taken any c++ in college, i'm more of an amateur programmer. i learnt php and vb by myself, thought c++ couldn't be too hard.
i see now that it has completely different princples and syntax, that's why i'm mistaking in the firstplace.
i don't think i made any mistakes, since i just copy-pasted, in the hope that it would compile. i genneraly copy-paste, compile, and latter analyze and make my own stuff out of examples.
here is the current code:
Code:
#include <windows.h>
#include <stdio.h>
// Standard libraries (STL)
#include <iostream> // cin, cout, cerr etc.
#include <list> // linked list
#include <string> // standard string class
// using directives to save on typing
using std::cout;
using std::cerr;
using std::string;
using std::list;
// could use this instead if it makes you feel better
// using namespace std;
int main(int argc, char *argv[])
{
typedef list<int> IntList; // makes life easier later
IntList v;
v.assign( 10, 42 );
// create an iterator and increment it until it reaches the end of the list
for(IntList::iterator iter = v.begin(); iter != v.end(); ++iter )
{
// printf?!? This is C++, boy! we don't use no stinking printf! :-)
cout << *iter; // *iter dereferences the iterator (kinda like a pointer)
}
// system("pause"); ugh, badness
cin.ignore();
cin.get();
}