-3
#include <iostream>

using namespace std;

int main()

{
 int a;
 int b;
 int sum;
 cout << "Enter a number boss \n";
 cin >> a;

 cout << "Enter another number \n";
 cin >> b;

 sum = a + b;
 cout << sum;
 return 0;
}

I tried to build a basic calculator which prints the sum of two numbers provided by the user in the code above in C++. But during linking it shows that there are multiple definition of main. How can i fix this?

user207421
  • 305,947
  • 44
  • 307
  • 483
  • 2
    The problem doesn't lie in your code. It's most likely because you're having multiple files in the C::B project. – user202729 Jul 18 '18 at 02:30
  • 1
    **Possible duplicates:** https://stackoverflow.com/questions/49496957/codeblocks-error-multiple-definition-of-main ; https://stackoverflow.com/questions/34856493/multiple-definition-of-main-first-defined-here ; https://stackoverflow.com/questions/26626134/gnu-gcc-compilor-error-multiple-definition-of-main – user202729 Jul 18 '18 at 02:31
  • During *linking* it said there are multiple definitions of `main`. – user207421 Jul 18 '18 at 04:20

1 Answers1

0

Search main in other files and just delete or comment those lines out.

Amit Verma
  • 8,660
  • 8
  • 35
  • 40