previous | start | next

2.4 The template version of intArray

#ifndef ARRAY_H
#define ARRAY_H

#include <iostream>

using namespace std;

template <class T>
class Array
{
  T *arr;
  int arr_size;
  int arr_capacity;
  void grow(int new_capacity);
public:
  Array();
  Array(int sz);
  Array(const Array& other); // 1. copy constructor

  T& at(int i);
  const T& at(int i) const;
  void add(const T& x);

  void operator=(const Array& other); // 2. assignment

  int size() const;
  ~Array();  // 3. destructor
};
   


previous | start | next