Hello All,
I have writtern a c++ code to implement Koch Snowflake pattern using recursion. The code written compiled well but did not run saying linking error for some variables as shown below:
============================
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _moveto referenced in function "public: __thiscall RecursiveCurve::RecursiveCurve(void)" (??0RecursiveCurve@@QAE@XZ)
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _setbkcolor referenced in function "public: __thiscall RecursiveCurve::RecursiveCurve(void)" (??0RecursiveCurve@@QAE@XZ)
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _setcolor referenced in function "public: __thiscall RecursiveCurve::RecursiveCurve(void)" (??0RecursiveCurve@@QAE@XZ)
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _linerel referenced in function "private: void __thiscall RecursiveCurve::drawFourLines(double,int)" (?drawFourLines@RecursiveCurve@@AAEXNH@Z)
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _grapherrormsg referenced in function _main
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _graphresult referenced in function _main
1>kosh_snowflake.obj : error LNK2019: unresolved external symbol _initgraph referenced in function _main
I am not able to get rid of these errors. Any immediate help would be appreciated.
Below is my code attached:
#define _USE_MATH_DEFINES
#include<iostream>
#include<graphics.h>
//#include<math.h>
#include<winbgi.h>
#include<cmath>
using namespace std;
class RecursiveCurve{
public:
RecursiveCurve();
void readInitValues();
void snowflake();
private:
double side, angle;
int level;
void right(double x){
angle+= x;
}
void left(double x){
angle -= x;
}
void drawFourLines(double side, int level);
};
RecursiveCurve::RecursiveCurve(){
setcolor(WHITE);
setbkcolor(BLUE);
moveto(200,150);
angle = 0.0;
cout<<"Enter Side and Level: ";
cin>>side>>level;
}
void RecursiveCurve::drawFourLines(double side, int level){
if(level == 0)
linerel((cos(angle*M_PI/180)*side),sin(angle*M_PI/180));
else{
drawFourLines(side/3.0,level-1);
left(60);
drawFourLines(side/3.0,level-1);
right(120);
drawFourLines(side/3.0,level-1);
left(60);
drawFourLines(side/3.0,level-1);
}
}
void RecursiveCurve::snowflake(){
for (int i=1;i<=3;i++){
drawFourLines(side,level);
right(120);
}
}
void main(){
int grBoard = DETECT, grMode, grResult, grError;
initgraph(&grBoard,&grMode, "C:\\Users\\skumar483\\Documents\\Visual Studio 2010\\Projects\\Koch_snowflake\\Koch_snowflake\\bgi");
grError = graphresult();
if (grError != grOk){
cerr<<"error: "<<grapherrormsg(grError)<<endl;
}
RecursiveCurve curve;
curve.snowflake();
}