I'm writing a program that makes a class Array. It creates an array of objects of any type - whether it be an array of ints, doubles, strings or chars. At this stage, I'm merely trying to set up a class of int Arrays. I'll turn it into a template afterwards.
I'm getting a strange error when I try to compile. This is my first time working with copy constructors, and I am certain that I am doing something wrong, but I don't see what.
Here is my code (trimmed down a bit):
**Note, this is my .h and .cpp all merged into one .h file. It is structured in this way because my ultimate goal is to make a template out of this program.
//The Header File of class Array
//prevent multiple inclusions of header file
using namespace std;
friend ostream & operator << (ostream &, const Array &);
friend istream & operator >> (istream &, Array &);
Array(int = DEFAULTSIZE); // default constructor
Array(const Array&); // copy constructor
~Array(); // destructor
static const int DELIM = -999; // example of using a delimiter to signal end of input
static const int DEFAULTSIZE = 10; // default array size
Array::Array(s = DEFAULTSIZE)
if(s <= 0)
size = DEFAULTSIZE;
size = s;
arr = new int[size];
cerr << "error\n";
Array::Array(const Array & copy)
arr = copy.arr;
arr = NULL;
The error occurs on line 33. It says this:
Array.h:59:13: error: expected constructor, destructor, or type conversion before â(â token
I find this confusing because the compiler is expecting a constructor and in doing so preventing me from writing the constructor!