Please remind me........

Hi peeps,

Could someone please remind me what <int> means in the code below. I know i learnt it a couple of weeks ago, but have forgot and can't remember where i read about it.
Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>
#include <iostream>
int main()
{
    using namespace std;
 
    vector<int> vect;
    for (int nCount=0; nCount < 6; nCount++)
        vect.push_back(10 - nCount); // insert at end of array
 
    for (int nIndex=0; nIndex < vect.size(); nIndex++)
        cout << vect[nIndex] << " ";
 
    cout << endl;
}
Last edited on
It's a template instantiation. Templates allow you to reuse code for different types as long as all operations used are supported for that type. In the example you posted, you use the generic type vector. The compiler will then create a vector of int. You can change the type to use vector for nearly any type.
Last edited on
Many many thanks! :)

.......Dazzer
Topic archived. No new replies allowed.