This program:
#include <iostream> using namespace std; int main() { cout << "Enter a number"; int i; cin >> i; try { if( i == 0 ) throw 0; if( i == 2 ) throw "error"; } catch( int i ) { cout << "can't divide by 0"; } catch( ... ) { cout << "catching other exceptions"; } }
When compiling (Microsoft Visual C ++ 2010 Express on Windows 7) I get an error message:
fatal error LNK1169: one or more multiple-found characters found
There is actually no error in this code .
There may be a problem with the number of source files. Try this code as a new project in the same compiler or try deleting files from the option source fileson the left side of the text area (where you write your code)
source files
.
, , , , , main (int main) .cpp , .cpp (int main()).so , . , .cpp (int main), .cpp (int submain) , .
int main() int submain().
int main()
int submain()
I suspect your error comes from this line:
catch(int i)
You already have a variable named so in this range. In addition, you should catch exceptions, not an integer.