this is a 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";
}
}
On compiling (Microsoft visual C++ 2010 express on Windows 7), I get the error which says:
fatal error LNK1169: one or more multiply defined symbols found
Actually there is no error in this code.
Number of source files could be the problem.
Try this code as a new project in the same compiler or try deleting the files from the source files
option in the left side of Text Area (i.e where you are writing your code)
This should compile then.
Finally I think that I found the most plausible explanation for the problem as you know we usually assign main as an integer (int main) in our .cpp file and sometimes we may write more than one .cpp file in the same project with the same (int main () ).so for the program that means we have accidentally repeated the same function twice in the same project folder .What we have to do is this just write one .cpp file with (int main) while the other .cpp files in the same project write them with (int submain) and see what gona happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With