Mystring.h:26: error: expected type-specifier
<p>I am modifying code that was given to me to allow the throwing of exceptions. The problem is that the declarations don't seem to be accepting Error, the exception type as a valid class.</p>

<p>The code is below:</p>

<pre><code>// Interface for a simple String class to encapsulate a C character string

#ifndef _MYSTRING_H_
#define _MYSTRING_H_

#include &lt;string.h&gt;
#include &lt;iostream&gt;
#include &lt;stdexcept&gt;
using namespace std;

class MyString {
public:
    // Constructors and destructor
    MyString(const char * = ""); // Create from C string
    MyString(const MyString &amp;); // Copy constructor
    ~MyString() { delete [] sdata; }

    // Assignment
    MyString &amp; operator = (const MyString &amp;);
    MyString &amp; operator = (const char *);

    MyString &amp; operator += (const MyString &amp;);
    MyString &amp; operator += (const char &amp;);

    // Character access
    char &amp; operator [] (int i) throw(MyString::Error);
    char operator [] (int i) const throw(MyString::Error){
        return (i &lt; 0 || i &gt;= len) ? '\0' : sdata[i];
    }

    // Substrings
    MyString operator () (unsigned int start, unsigned int count) const throw(MyString::Error);

    // Concatenation
    MyString operator + (const MyString &amp;) const;
    MyString operator + (const char &amp;) const;

    // Cast to c string
    operator const char * () const { return sdata; }

    // Query methods
    unsigned int length() const { return len; }

    class Error: public exception{
        public:
            //ERROR CODES
            static const int SUBSTRING_ERR = 0;
            static const int INDEX_ERR  = 1;
            static const int ALLOC_ERR  = 2;

            int errorCode;
            int leftIndex;
            int count;
            int size;

            Error(int errCode){ //Alloc error
                errorCode = errCode;
            }
            Error(int errCode, int left, int len){ //Index error
                errorCode = errCode;
                leftIndex   = left;
                size        = len;
            }
            Error(int errCode, int left,int substrCount, int len){ //Substring error
                errorCode = errCode;
                leftIndex   = left;
                size        = len;
                count = substrCount;
            }

    };

private:
    char * sdata;           // Storage for the characters
    unsigned int len;       // Current length

    // Private constructor for pre-allocation
    MyString(const char *, unsigned int);  
};

inline ostream &amp; operator &lt;&lt; (ostream &amp; o, const MyString &amp; s) {
    return o &lt;&lt; (const char *) s;
}

inline bool operator == (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (::strcmp(lhs, rhs) == 0) ? true : false;
}

inline bool operator != (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (lhs == rhs) ? false : true;
}

inline bool operator &lt; (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (::strcmp(lhs, rhs) &lt; 0) ? true : false;
}

inline bool operator &gt;= (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (lhs &lt; rhs) ? false : true;
}

inline bool operator &gt; (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (::strcmp(lhs, rhs) &gt; 0) ? true : false;
}

inline bool operator &lt;= (const MyString  &amp; lhs, const MyString &amp; rhs) {
    return (lhs &gt; rhs) ? false : true;
}

inline ostream &amp; operator &lt;&lt; (ostream &amp; o, const MyString::Error &amp; s) {
    return o &lt;&lt; "NOM"; //TODO
}

#endif
</code></pre>

<p>Here is the full error message:</p>

<p>/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:26: error: expected type-specifier
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:26: error: expected <code>)'
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:26: error: expected ‘;’
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:27: error: expected type-specifier
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:27: error: expected</code>)'
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:27: error: expected ‘;’
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:32: error: expected <code>;' before ‘MyString’
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:32: error: expected type-specifier
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:32: error: expected</code>)'
/Users/alexanderstein/Documents/School/2011-2012/Term 3/CIS 330/6/Mystring.h:32: error: expected ‘;’</p>
