Exceptions
Vectors
Functions
100
What will this do?

std::stoi("b");
throws an std::invalid_argument exception
100
How do I create a new std::vector of int's?
vector<int> vecOfInts;
100
What does this do?
void SetsToFive(int& x)
{
x = 5;
}
/**************************/
int n = 10;
SetsToFive(x);
std::cout << n << std::endl;
5
200
What will this do?
std::ifstream myFile;
myFile.open("does_not_exist.txt");
Nothing
200
How do I get this vector's size?
std::vector<std::string> someVec;
someVec.size()
200
What does this do?
void SetsToBlank(std::string& x)
{
x = "";
}
/**************************/
std::string n = "something";
SetsToBlank(n);
std::cout << n << std::endl;
[intentionally blank]
300
What will this do?
std::vector v;
v.push_back(5639);
v.at(1);
it'll throw a std::out_of_range exception.
300
Create a std::vector of std::string's and put the first names of your team mates in it.
std::vector<std::string> teamList;

teamList.push_back("example1");
teamList.push_back("example2");
300
void MayThrowException(int& x)
{
	if (x < 0)
	{
		throw std::exception("x is less than 0");
	}
}

int main()
{

	try
	{
		int n = -5;
		MayThrowException(n);
	}
	catch (std::exception& e)
	{

		std::cerr << e.what() << std::endl;
	}
}
x is less than 0
400
What will this do?
try
{
std::cout << "hi there" << std::endl;
} catch(std::exception e)
{
std::cerr << "ERROR" << std::endl;
}
hi there
400
What will the following code do?
std::vector<int> vecOfInts;
int firstInt = vecOfInts.at(1);
It will compile, but throw a out_of_range exception at runtime.
400
void SetsBothToZero(int& x, int y)
{
	x = 0;
	y = 0;
}

/******************************/
	int a = 6;
	int b = 6;
	SetsBothToZero(a, b);
        std::cout << "a=" << a << ",b=" << b << std::endl;

a=0,b=6
500
What will this do?
        void ThrowsAnException()
        {
            std::vector v;
            v.at(0);
            std::cout << "I just tried to access an invalid location"<< std::endl;
        }

        static void Main(string[] args)
        {
            try
            {
                ThrowsAnException();
            }
            catch(std::out_of_range& e)
            {
                std::cout << "ERROR: Invalid access" << std::endl;
            }
        }
ERROR: Invalid access
500
Will will this do?
            std::vector<int> vecOfInts;
            vecOfInts.push_back(3);
            vecOfInts.push_back(2);
            vecOfInts.push_back(1);
            for(int i : vecOfInts)
            {
                std::cout << i << std::endl;
            }
3
2
1
500
void doSomethingCrazy(int n)
{
	for (int i = 0; i < n; ++i)
	{
		if (i < 10)
		{
			throw std::runtime_error("bad i=" + std::to_string(i));
		}
	}
}

int main(int argc, char* argv[])
{
	int n = 10;
	try
	{
		doSomethingCrazy(n);
	}
	catch (std::runtime_error& e)
	{
		std::cerr << e.what() << std::endl;
	}
}
bad i=0
M
e
n
u