// -*- coding: utf-8 -*- // Time-stamp: // Examples of accessors with a class containing a fixed array #ifndef ACCESSORS_H #define ACCESSORS_H // Class containing an array with many accessors class Array { public: // Get size int size() const { return n; } // Getter double get(int i) const; // Setter void set(int i, double v); // Accessor using pointer double* access(int i); // Accessor to const object using pointer const double* access(int i) const; // Accessor using reference double& operator[](int i); // Accessor to const object using reference const double& operator[](int i) const; private: static const int n = 10; // Size of the array double a[n]; // Array in the object }; #endif