At school I'm in AP Computer Science and one of our projects in java was to make a program with the quadratic equation. That wasn't too hard in java. So I decided to do it in C++ for fun today and here is my code:
Code:
The only error I got from this was saying:
"1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Programming\C++\Projects\quad2\Debug\quad2.exe : fatal error LNK1120: 1 unresolved externals"
Can anyone explain what i'm doing wrong?
Code:
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
class QuadraticEquation
{
public:
class QuadraticEquation(double a1, double a2, double a3){
a = a1;
b = a2;
c = a3;
};
bool hasSolutions(){
if (solution1>0) {return true;}
else {return false;}
};
double getSolution1(){
solution1 = (-b+(sqrt((b*b)-(4*a*c))))/2;
solution2 = (-b-(sqrt((b*b)-(4*a*c))))/2;
if(solution1>solution2) {return solution1;}
else {return solution2;}
};
double getSolution2(){
solution1 = (-b+(sqrt((b*b)-(4*a*c))))/2;
solution2 = (-b+(sqrt((b*b)-(4*a*c))))/2;
if(solution1>solution2) {return solution2;}
else {return solution1;}
};
private:
double a;
double b;
double c;
double solution1;
double solution2;
};
int main()
{
QuadraticEquation quad(1,-2,-17);
cout<<quad.getSolution1();
cout<<quad.getSolution2();
cout<<quad.hasSolutions();
cin.get();
return 0;
}
The only error I got from this was saying:
"1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Programming\C++\Projects\quad2\Debug\quad2.exe : fatal error LNK1120: 1 unresolved externals"
Can anyone explain what i'm doing wrong?