#include #include using namespace std; class Squares: vector { public: Squares(unsigned n) : vector (n) { for (unsigned k = 0; k < n; k++) (*this)[k] = k * k; } ostream& print(ostream& out) const { const_iterator pos; // must be const_iterator for (pos = begin(); pos != end(); pos++) out << *pos << endl; return out; } }; int main() { Squares sq(10); sq.print(cout); }