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.
//error.h
class ERROR
{
public:
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;};
private:
char * m_message;
};
//array.h
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];
}
//main.cpp
for(int i(arrInt2.getStartIndex()); i<arrInt2.getLength()+arrInt2.getStartIndex()+1; i++)
{
try{std::cout<<arrInt2[i]<<" ";}
catch(ERROR *er)
{
er->GetMessage();
}
}
anything you guys see?