Exception Unhandled Error when trying to use function in catch block : <p>I am trying to run a simple code where an error is throw when the its looking for a vector position out of range. But when I run the code, I get an error</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;

void error()
{
    throw(" a standard exception was caught, with message \n");
}

int main() {

    try {
        cout &lt;&lt; "Creating a vector of size 5... \n";
        vector&lt;int&gt; v(5);
        cout &lt;&lt; "Accessing the 11th element of the vector...\n";
        cout &lt;&lt; v.at(10);
    }
    catch (const exception&amp; e) {
        error();
    }
    system("PAUSE");
    return 0;
}
</code></pre>
