// Een dozijn van een willekeurig type T

#include <iostream>
#include <string>
using namespace std;

template<typename T> class Dozijn {
public:
	void zetIn(int index, const T& waarde);
	const T& leesUit(int index) const;
private:
	T data[12];
};

template<typename T> void Dozijn<T>::zetIn(int index, const T& waarde) {
	if (index>=0 && index<12) 
		data[index]=waarde;
}

template<typename T> const T& Dozijn<T>::leesUit(int index) const {
	if (index<0)
		index=0;
	if (index>11)
		index=11;
	return data[index];
}

template<typename T> ostream& operator<<(ostream& o, const Dozijn<T>& d) {
	o<<d.leesUit(0);
	for (int i=1; i<12; ++i)
		o<<", "<<d.leesUit(i);
	return o;
}

int main() {
	Dozijn<int> d1;
	for (int j=0; j<12; ++j)
		d1.zetIn(j, j*j);	// vul d1 met kwadraten
	cout<<"d1 = "<<d1<<endl;
	Dozijn<string> d2;
	d2.zetIn(0, "Drenthe");
	d2.zetIn(1, "Flevoland");
	d2.zetIn(2, "Friesland");
	d2.zetIn(3, "Gelderland");
	d2.zetIn(4, "Groningen");
	d2.zetIn(5, "Limburg");
	d2.zetIn(6, "Noord-Brabant");
	d2.zetIn(7, "Noord-Holland");
	d2.zetIn(8, "Overijssel");
	d2.zetIn(9, "Utrecht");
	d2.zetIn(10, "Zeeland");
	d2.zetIn(11, "Zuid-Holland");
	cout<<"d2 = "<<d2<<endl;   
	cin.get();
	return 0;
}
