Hi guys i am making binary tree in graphics.h the problem is that it opens multiple windows and also gives error...please help
#include <iostream> #include <graphics.h> using namespace std; class Graph { private: int cCordX; int cCordY; int cRadius; int tCordX; int tCordY; int lRightCordX1; int lRightCordY1; int lRightCordX2; int lRightCordY2; int lLeftCordX1; int lLeftCordY1; int lLeftCordY2; int lLeftCordX2; public: Graph(); void makeCircle(char); void drawLeftLine(); void drawRightLine(); }; Graph::Graph() { initwindow(800,500); //Circle cCordX = 400 ; cCordY = 50 ; cRadius = 15 ; //Text tCordX = 392 ; tCordY = 45 ; //Right Cords lRightCordX1 = 400; lRightCordY1 = 65; lRightCordX2 = 450; lRightCordY2 = 100; //Left Cords lLeftCordX1 = 400; lLeftCordY1 = 65; lLeftCordX2 = 350; lLeftCordY2 = 100; } void Graph:: makeCircle(char a) { circle(cCordX , cCordY , cRadius); outtextxy(tCordX,tCordY,"15"); // Parameters(x-axis,y-axis,radius)(392,45,"15") } void Graph::drawRightLine() { line(lRightCordX1,lRightCordY1,lRightCordX2,lRightCordY2); //(400,65,350,100) Rigth } void Graph::drawLeftLine() { line(lLeftCordX1,lLeftCordY1,lLeftCordX2,lLeftCordY2); //(400,65,350,100) Left } class Tree:public Graph { private: int data; Tree *left,*rigth,*root,*newNode,*branch; public: void append(int); }; void Tree :: append(int a) { Graph(); makeCircle('2'); drawLeftLine(); drawRightLine(); newNode = new Tree; newNode->data = a; newNode->left = newNode->rigth = NULL; if(root == NULL) { root = newNode; } else { branch = root; while(branch != NULL) { if(branch->data > a) { if(branch->rigth) { branch = branch->rigth ; } else { branch->rigth = newNode; break; } } else if(branch->data < a) { if(branch->left) { branch = branch->left; } else { branch->left = newNode; break; } } else { cout<<"Dublicate Value"<<endl; } } } }; int main() { /* request autodetection */ int gdriver = DETECT, gmode, errorcode; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); Tree st; st. append(1); st. append(1); system("PAUSE"); exit(1); }