Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TopCoder Coding environment linker error

Tags:

c++

I am trying to submit a solution to a problem in TopCoder, which requires a submission to follow its predefined classes and methods. Since I am new to TopCoder, I am mostly trying to adjust to the coding interface. This code compiles perfectly on my computer. Unfortunately on TopCoder, I have been getting the errors:

Your code did not compile:

errors linking:

AdditionGame-stub.o: In function main': AdditionGame-stub.cc:(.text.startup+0x0): multiple definition ofmain' AdditionGame.o:AdditionGame-stub.cc:(.text.startup+0x0): first defined here collect2: error: ld returned 1 exit status

Help Please. Here is my code:

 class AdditionGame {

public:

int getMaximumPoints(int a, int b, int c, int n){
        int temp;
        if(a<b){temp=a; a=b; b=temp;}
        if(b<c){temp=b; b=c; c=temp;}

        int sum=0;
        for(int i=0; i<n; i++){
            if(a>0){sum=sum+a;}
            if(a>0){a=a-1;}
            if(a<b){temp=a; a=b; b=temp;}
        if(b<c){temp=b; b=c; c=temp;}
        }

        return sum;
    }

};


#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    AdditionGame add;
int A,B,C,N;

cin>>A>>B>>C>>N;

int p = add.getMaximumPoints(A, B, C, N);
 cout<<p;
return 0;
}`
like image 602
drewyu Avatar asked Jul 25 '15 15:07

drewyu


1 Answers

Looks like TopCoder is defining the main() function for you, based on your error message.

like image 119
rholmes Avatar answered Oct 23 '22 04:10

rholmes