#include <iostream>
#include <exception>
int main () {
shortint number = 0; // should only go up to 32767
int A = 0;
do {
try
{
number++;
}
catch (const std::exception &e)
{
std::cout << "Standard exception: " << e.what() << "\n";
A = 1;
}
if (number == 32767) {
std::cout << "At 32767 \n";
}
} while (A == 0);
return 0;
}
Nobody. I'm just trying things until I understand how they work.
I'm not taking a class on this so the only way to figure out what is wrong with my bad ideas is to post them here.
I saw this on the exceptions page as a type of exception "operator="
I figured maybe since N++ is the same as N = N + 1 it would do something.
What is the purpose of exception again?
I assumed it acted sort of like an If (something) {}
except that it was for when something unexpected happened so you could tell the program to do something else. Maybe exiting a loop is bad form but I don't know much about this stuff yet.
It is likely I have the wrong idea of when to use an exception and how.