#include <iostream.h>

class IntArray{
	static const int nDefaultArraySize = 10;
	int _nSize;
	int *nia;

    public:
	explicit IntArray(int pvnSize = nDefaultArraySize);
	IntArray(int *nArray, int nArraySize);
	IntArray(const IntArray &rhs);

	//Virtual Destructor
	virtual ~IntArray(){ delete [] nia;}

	//Equality and inequality operations
	bool operator==(const IntArray &) const;
	bool operator!=(const IntArray &) const;
		
	IntArray& operator=(const IntArray&);
	IntArray& operator=(const int*);
	int size() const{return _nSize;}

	//Overloading subscript operator
	virtual int& operator[](int pvnIndex) const {return nia[pvnIndex];}
		
	//Overload << and >> operators
	friend istream &operator>>(istream&, IntArray &);
	friend ostream &operator<<(ostream&, const IntArray &);
};

IntArray::IntArray(int pvnSize){
	_nSize = pvnSize;
	nia = new int[_nSize];

	for (int nIndx = 0; nIndx < _nSize; nIndx++)
		nia[nIndx] = 0;
	
}

IntArray::IntArray(int *pnArray, int pvnSize){
	_nSize = pvnSize;
	nia = new int[_nSize];

	for (int nIndx = 0; nIndx < _nSize; nIndx++)
		nia[nIndx] = pnArray[nIndx];
}

IntArray::IntArray(const IntArray &rhs){
	_nSize = rhs._nSize;
	nia = new int[_nSize];

	for (int nIndx = 0; nIndx < _nSize; nIndx++)
		nia[nIndx] = rhs.nia[nIndx];
	
}

bool IntArray::operator==(const IntArray &pnobjArr) const{
	if (size() == pnobjArr.size()){
		for (int nIndex = 0; nIndex < size(); nIndex++){
			if(nia[nIndex] != pnobjArr[nIndex])
				return false;
		}
	}

	return true; 
}

bool IntArray::operator!=(const IntArray &pnobjArr) const{
	if (size() == pnobjArr.size()){
		for (int nIndex = 0; nIndex < size(); nIndex++){
			if(nia[nIndex] != pnobjArr[nIndex])
				return true; 
		}
	}

	return false;
	
}

IntArray& IntArray::operator=(const IntArray &pobjArr) {
	_nSize = pobjArr.size();

	for(int nIndex = 0; nIndex < _nSize; nIndex++)
		nia[nIndex] = pobjArr[nIndex];
	
	return *this;
}

IntArray& IntArray::operator=(const int *pnArr){
	_nSize = sizeof(pnArr); 
	nia = new int[_nSize];

	for (int nIndx = 0; nIndx < _nSize; nIndx++)
		nia[nIndx] = pnArr[nIndx];

	return *this;
}

istream& operator>>(istream &input, IntArray &pobjArr){
	int nArray[pobjArr.size()];

	for(int nIndex = 0; nIndex < pobjArr.size(); nIndex++)
		input >> nArray[nIndex];
	
	pobjArr = nArray;
	
	return input;
}

ostream& operator<<(ostream &output, IntArray &pobjArr){
	for (int nIndex = 0; nIndex < pobjArr.size(); nIndex++){
		output << "The " << nIndex << " th element is:  " 
				<< pobjArr[nIndex] << endl;
	}

	return output;
}

int main(){

 	int nArray[4] = {12, 34, 56, 78};
	IntArray objArr1(nArray, 4);
	IntArray objArr2;

	cout << "Enter 4 integer values:  ";
	cin >> objArr2;

	cout << objArr1;
	cout << objArr2;

}