This is my code, the exact error is at the bottom, I've looked throughout stack overflow and can't find an answer to my question. I have no idea why I'm getting this error
//amer_bi.h
#include <iostream>
using namespace std;
class amer_bi
{
public:
int steps,i,j;
double risk_free, price, strike, ttm, u, d, p, vol, disc, dt;
char sw;
double OptionPrice(double, double, double, double, double);
double max(double , double);
};
//amer_bi.cpp
#include "amer_bi.h"
#include <iostream>
#include <math.h>
#include <fstream>
#include <string>
#include <stdio.h>
using namespace std;
#include <string>
//max function create
double max( double d1, double d2 )
{
return ( d1 > d2 ) ? d1 : d2;
}
double OptionPrice(double risk_free, double price, double strike, double ttm, double vol)
{
int steps;
steps = 200;
int i;
int j;
const int rows = steps+1;
const int cols = steps+1;
double dt = ttm/steps;
double u = exp(vol*sqrt(dt));
double d = exp(-vol*sqrt(dt));
double p = .5 + ((risk_free - .5*vol*vol)/(2*vol))*sqrt(dt);
double disc = exp(-risk_free*dt);
//pointer code for multidimensional dynamic array
double **price_array;
double **disc_array;
double **call_array;
price_array=new double*[rows];
disc_array=new double*[rows];
call_array=new double*[rows];
for(int i=0; i<rows; ++i)
{
price_array[i]=new double[cols];
disc_array[i]=new double[cols];
call_array[i]=new double[cols];
}
/*
//test data for book example
u = 1.1;
d = .9091;
disc = .9802;
p = .5820;
*/
char sw = 'c';
disc_array[steps][steps] = price*pow(d,steps);
for (i=steps; i > 0; i--)
{
disc_array[i-1][steps] = disc_array[i][steps]*u/d;
}
for (i=steps; i>=0; i--)
{
for (j=steps-1; j>=0; j--)
{
disc_array[i][j] = disc_array[i][j+1]*d;
}
}
for (i=steps; i >= 0; i--)
{
if (sw == 'c')
call_array[i][steps] = max(disc_array[i][steps] - strike, 0);
else
call_array[i][steps] = max(strike - disc_array[i][steps], 0);
}
price_array[0][steps] = price*pow(d,steps);
for (i=steps-1; i >=0; i--)
{
for (j=steps-1; j>=0; j--)
{
if (sw == 'c')
call_array[i][j] = max(disc*(p*call_array[i][j+1] + (1-p)*call_array[i+1][j+1]), disc_array[i][j] - strike);
else
call_array[i][j] = max(disc*(p*call_array[i][j+1] + (1-p)*call_array[i+1][j+1]), strike - disc_array[i][j]);
}
}
//std::cout << call_array[0][0] << endl;
return call_array[0][0];
}
//top.cpp
#include <iostream>
#include "amer_bi.h"
using namespace std;
int main ()
{
amer_bi exa;
exa.OptionPrice(.06, 100.0, 120.0, 1.0, .2);
system("pause");
return 0;
}
error LNK2019: unresolved external symbol "public: double __thiscall amer_bi::OptionPrice(double,double,double,double,double)" (?OptionPrice@amer_bi@@QAENNNNNN@Z) referenced in function _main 1>C:\Users\Class2017\Documents\Visual Studio 2010\Projects\QF 465\Debug\amer_bi.exe : fatal error LNK1120: