| | |
Graphics in Microsoft C
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2006
Posts: 40
Reputation:
Solved Threads: 2
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:
Your replies are highly appreciated. Thanking you,
Regds,
Beuls
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:
C++ Syntax (Toggle Plain Text)
#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); }
Regds,
Beuls
Last edited by Dave Sinkula; Jan 11th, 2006 at 2:25 pm. Reason: Fixed [code][/code] tags.
![]() |
Similar Threads
- Internet Explorer Graphics Run Slow (Web Browsers)
- Windows Vista (IT Professionals' Lounge)
- Visual C++ graphics (C++)
- Another Webmaster in the Works (Site Layout and Usability)
- ATI Radeon 7000 crapy graphics (Monitors, Displays and Video Cards)
Other Threads in the C++ Forum
- Previous Thread: Passing variables around in a MFC project
- Next Thread: C++ arrays and random numbers
Views: 3400 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






