Dear programmers,

I have developed a graphics program in C++ to draw various shapes using virtual functions. While using the Turbo C compiler the graphics.h file is included to use the graphics functions. But now i am using the Visual C++ (MS Visual Studio 6.0) compiler. so what modifications shd i do? I am giving the code below:

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
class s1
{
protected:
int x,y;
public:
void getda()
{
cout<<"Enter the X coordinate:";
cin>>x;
cout<<"Enter the Y coordinate";
cin>>y;
}
virtual void draw()=0;
};
class lineq:public s1
{
public:
int x1,y1;
void get()
{
cout<<"Enter the X cordinate:";
cin>>x1;
cout<<"Enter the Y Cordiante";
cin>>y1;
}
void draw()
{
line(x,y,x1,y1);
}
};
class circ:public s1
{
public:
int r;
void get1()
{
cout<<"Enter the radius";
cin>>r;
}
void draw()
{
circle(x,y,r);
}
};
class rect:public s1
{
public:
int w;
void get1()
{
cout<<"Enter the width";
cin>>w;
}
void draw()
{
rectangle(x-w,y-w,x+w,y+w);
}
};
void main()
{
int gd=DETECT ,gm,ch;
initgraph(&gd,&gm,"s:\\appl\\tcplus\\include");
do
{
cout<<"Shapes Menu"<<endl;
cout<<"1.Line"<<endl;
cout<<"2.Circle"<<endl;
cout<<"3.Rectangle"<<endl;
cout<<"4.Exit"<<endl;
cout<<"Enter your choice";
cin>>ch;
switch(ch)
{
case 1:
clrscr();
lineq l1;
l1.getda();
l1.get();
s1 *ptr;
ptr=&l1;
clrscr();
ptr->draw();
getch();
break;
case 2:
clrscr();
circ c1;
c1.getda();
c1.get1();
ptr=&c1;
clrscr();
ptr->draw();
getch();
break;
case 3:
clrscr();
rect r1;
r1.getda();
r1.get1();
ptr=&r1;
clrscr();
ptr->draw();
getch();
break;
case 4:
exit(0);
}
cout<<"press any key to continue";
getch();
clrscr();
}
while(1);
}

Your replies are highly appreciated. Thanking you,

Regds,
Beuls

graphics.h wont work with Visual C++. You have to learn win32 APIs.

what modifications shd i do

A complete (or nearly complete) rewrite. There could be a port of graphics.h to win32, but I have't heard of any. google around a little to see what you can find there.

A complete (or nearly complete) rewrite. There could be a port of graphics.h to win32, but I have't heard of any. google around a little to see what you can find there.

Thank you

Thx

Beuls

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.