// vector assign
#include <iostream>
#include <vector>
usingnamespace std;
int main ()
{
vector<int> first;
vector<int> second;
vector<int> third;
first.assign (7,100); // a repetition 7 times of value 100
vector<int>::iterator it;
it=first.begin()+1;
second.assign (it,first.end()-1); // the 5 central values of first
int myints[] = {1776,7,4};
third.assign (myints,myints+3); // assigning from array.
cout << "Size of first: " << int (first.size()) << endl;
cout << "Size of second: " << int (second.size()) << endl;
cout << "Size of third: " << int (third.size()) << endl;
return 0;
}
No, I'm not sure. I'm researching vector because I'm having a problem with an exercise in the book I'm reading. I copied this code from cplusplus.com so I could do some experimenting.
Make sure that this is a console application project. What IDE do you use? Create a new project and select console application.
main indicates the entry point in console applications. My guess is that your project is something else whose entry point is indicated in some other way (for example in a windows application the entry point is WinMain)
Thanks m4ster r0shi, that was the problem. I put it into jEdit and got the error. As you suggested I created a new project in VC++ Express Edition and it compiled and executed without error. Although VC++ Express adds a half dozen files I don't understand I think I'll use it from now on.