MMmmmmk so what i am trying to do is simply throw a the ERROR object from the Array<T>::operator[] and catch it in main take a took... it prints out the equivalent of an empty space in memory.

class ERROR
	ERROR(char * Incomming)
		m_message = new char[strlen(Incomming)+1];
		strcpy(m_message, Incomming);
	void GetMessage(){std::cerr<<m_message<<std::endl;};
	~ERROR(){delete m_message;};
	char * m_message;


template <typename T>
T &Array<T>::operator[](int const &index)    //throw(ERROR) doesn't work
	int newindex = index - m_start_index;

		if(newindex == m_length)
			throw ERROR("Out Of Bounds");

	return m_array[newindex];

for(int i(arrInt2.getStartIndex()); i<arrInt2.getLength()+arrInt2.getStartIndex()+1; i++)
	try{std::cout<<arrInt2[i]<<" ";}
	catch(ERROR *er)


anything you guys see?

don't try to catch a pointer to the object, because you have thrown the ERROR object (not a pointer to the ERROR object).

use catch(ERROR &er){er.GetMessage();} in the main code.

you could also use catch(ERROR er){er.GetMessage();} in the main code.

its just a pointer because i was swapping em out, trying const ref, ref, value, pointer etc and it just ended up at pointer when i posted... but i made the ERROR class canonical and it worked thanks!

This question has already been answered. Start a new discussion instead.