c++ compilation error

Hi All,

I am trying to compile c++ program and I am getting following error

jagadish@linux-ekk5:~> g++ maxtriangle.cpp -o maxtriangle.o

/usr/lib/gcc/i586-suse-linux/4.3/…/…/…/crt1.o: In function _start': (.text+0x18): undefined reference to main’
collect2: ld returned 1 exit status

Can anyone plz help me out with this error,thank u.

It looks like you do not have the main() function in your source file.

Usually the function looks like this:

int main(int argc, char* argv])
{

}

yeah you are right that there is no main() in the c++ source code.The source code is as follows:

#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <sstream>

#pragma comment(linker, “/STACK:60777216”)

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define UN(v) SORT(v),v.erase(unique(v.begin(),v.end()),v.end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define CL(a,b) memset(a,b,sizeof(a))
#define pb push_back

const int inf = 1011111111;

vector<pii> solve(int A){
vector<pii> v;
for(ll i=0;ii<=A;i++){
int j=A-i
i;
int k=sqrt(j+0.)+0.1;
if(k*k==j){
v.pb(pii(i,k));
v.pb(pii(-i,k));
v.pb(pii(i,-k));
v.pb(pii(-i,-k));
}
}
return v;
}

class MaxTriangle {
public:
double calculateArea(int A, int B) {
vector<pii> v1=solve(A),v2=solve(B);

double res=-1;
REP(i,v1.size()) REP(j,v2.size()){
double sq=v1*.firstdouble(v2[j].second)-double(v1.second)*v2[j].first;
if(sq<0) sq=-sq;
sq/=2;
if(sq>1e-10) res=max(res,sq);
}
return res;
}

};

Then how to execute the above code without main()?
If I use the following command

g++ -c maxtriangle.cpp -o maxtriangle.o

It just compiles and I am not able to execute it.**

The program has two problems.

Maybe you would like to introduce main() before the line
vector<pii> solve(int A){

Like this:
int main()
{
vector…

return 0;
}

Second: you have declared MaxTriangle class, but do not use it.

Read a basic book on C or C++ programming.

Without main there is no execution.