Crossroads Logo ACM Logo ACM Crossroads Student Magazine
The ACM's First Electronic Publication
 
Crossroads Home
Join the ACM!
Search Crossroads
crossroads@acm.org
About Crossroads
Participate!
Submit Article
Subscribe
Link to us!
Index:
   Back Issues
   Articles By Topic
   Columns
   Reviews
   Student Resources

Press Room
Privacy Statement
Crossroads en Español
ACMCrossroads / Xrds1-2 / Definition of the IArray Class

Figure 1: Definition of the IArray class.

// Class definition for an integer array
//
#ifndef IARRAY2_H
#define IARRAY2_H

#include 

class IArray
{
private:
   enum {DefaultSize = 12};

   // Internal representation
   int size;
   int *data;

  void Init (const int* d, int s);

public:
   // Default constructor
   IArray (int sz = DefaultSize);

   // Another useful constructor
   IArray (const int* d, int sz);

   // Copy constructor
   IArray (const IArray& ia);

   // Destructor
   ~IArray ();

   // Assignmet operator
   IArray& operator= (const IArray& a);

   // Subscript operator
   int& operator[] (int index);

   // Size
   int Size() const;

   // Output operator
   friend ostream& operator<< 
      (ostream& os, const IArray& a);
   
};

#endif

© Copyright 2000-2004 by ACM, Inc.

Page hits since December 20, 1999: