throw, try, except error

Can anyone pleas explain why this code is throwing "no opearator "<<" matches these opeands" error in 13th line?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main()
{
	try
	{
		throw - 1;
	}
	catch (int x)
	{
		cerr << "We caught: " << x << endl;
	}
	catch (const string &name)
	{
		cerr << "We caught: " << name << endl;
	}

	return 0;
}
Last edited on
Nothing wrong with that code.

https://ideone.com/EUuZnG
> no opearator "<<" matches these opeands

Likely: missing #include <string>
Oh...how could I forgot include string :/ Thanks!!!
Topic archived. No new replies allowed.