/*----
  signature: main: void -> int
  purpose: trying out C++ exception handling!

  compile using:
      g++ exc1.cpp -o exc1
  run using:
      ./exc1

  by: Sharon Tuttle
  last modified: 2022-11-17 - added this "opening" main stuff
                              (so this DOES compile and run)
                 2022-11-15 - in-class version
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <exception>
#include <vector>
using namespace std;

int main()
{
    int vector_size;

    // NOTE: this should be an if-statement,
    //    using exceptions as a demo-of-concept!!

    cout << "enter desired vector size: ";
    cin >> vector_size;

    try
    {
        if (vector_size < 0)
        {
            throw out_of_range("vector size cannot be negative");
        }

        cout << "Silly: dividing 10 by vector size: "
             << (10 / vector_size) << endl;
    }
    catch (out_of_range e)
    {
        cout << "exception thrown: "
             << e.what() << endl;
        vector_size = 0;
    }

    vector<string> my_collection(vector_size);

    cout << "my collection size: "
         << my_collection.size() << endl;

    return EXIT_SUCCESS;
}