/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto (root-cint@cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ /************************************************************************** * cpp6.c * * Array class * * Constructor, copy constructor, destructor, operator overloading * function overloading, reference type * **************************************************************************/ #include #include #include int nstore; /********************************************************** * class array **********************************************************/ struct array { double *dat; int n; array(const array& X); array(double x,int ndef); array(double x); ~array(); void print(void); void print(int n); array operator =(const array& a); } ; array::~array() { // abc free(dat); // printf("destroyed\n"); } // Copy constructor array::array(const array& X) { int i; // free(dat); dat = (double *)malloc(X.n*sizeof(double)); for(i=0;i