The STL is all called the Standard Template Library, which is basically a template, it relies on templates, not objects, so you need to instantiate this template and choose the type you want to use.
The template is a kind of thing, you can look at this TOJ5250
Test instructions is for me to implement an array of arbitrary content that can be placed in a variable length.
My implementation code
#include <iostream>#include<malloc.h>using namespacestd;template<typename t>classvector{PrivateTp; intsize; intN; Public: Vector () {p= (t*)malloc(Ten*sizeof(T)); Size=Ten; N=0;} voidPush_back (ConstT a) { if(n==size) {p= (t*)realloc(P,Ten*sizeof(T)); size+=Ten;} * (p+n) =A; N++; } typedef T*Iterator; T*Begin () {returnp;} T*End () {returnp+n;}};intVector, deque, list, forward_list, array,string;//prohibit the use of vectors, lists, etc.intMain () {Vector<int>A; for(intI=1; i<=5; i++) A.push_back (i); Vector<int>:: Iterator it; for(It=a.begin (); It!=a.end (); + +it) {cout<<*it<<Endl; }}
Inside I used some kind of things, for the moment skip.
void push_back (const T a) { if (n==size) {p= (t*) realloc (p,10*sizeof (T)); size+=10;} * (p+n) =A; n++; }
Well, look at this part.
Introduction and use of C + + STL in ACM