#include #include #include struct person { string fname, lname; // object's variables are MEMBERS. int ssn, bd; // object's functions are called METHODS void print() { cout << fname << " " << lname << ", SSN=" << ssn << ", born " << bd << "\n"; } person(int s, string f, string l, int b) { ssn = s; fname = f; lname = l; bd = b; } }; template struct database { protected: T * data; int size, nextfreeslot; public: int growth_amount; database(int initsize = 100) // if I provide a param, 100 is ignored. { size = initsize; growth_amount = size; nextfreeslot = 0; data = new T [size]; } /* database() { database(100); } NO you can't do that in C++ */ ~database() // destrcutor. always called automatically // when something ceases to exist. { delete [] data; data = NULL; } protected: void makeitgrow() { int newsize = size+growth_amount; T * newa = new T [newsize]; for (int i=0; inextfreeslot) { cout << "Error in put\n"; abort(); } if (pos==nextfreeslot) nextfreeslot += 1; if (pos>=size) makeitgrow(); return data[pos]; } }; void main() { database A(10); A.insert("asdasd"); A.insert("bdfgd"); A.insert("crtyhtfh"); A.insert("dhjkkk"); A.insert("ehkmhm"); A.insert("kyukufyh"); A.access(3) = "Changed!"; for (int i=0; i