Graphics in Microsoft C

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2006
Posts: 40
Reputation: beuls is an unknown quantity at this point 
Solved Threads: 2
beuls beuls is offline Offline
Light Poster

Graphics in Microsoft C

 
0
  #1
Jan 11th, 2006
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:

  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<conio.h>
  4. #include<stdlib.h>
  5. class s1
  6. {
  7. protected:
  8. int x,y;
  9. public:
  10. void getda()
  11. {
  12. cout<<"Enter the X coordinate:";
  13. cin>>x;
  14. cout<<"Enter the Y coordinate";
  15. cin>>y;
  16. }
  17. virtual void draw()=0;
  18. };
  19. class lineq:public s1
  20. {
  21. public:
  22. int x1,y1;
  23. void get()
  24. {
  25. cout<<"Enter the X cordinate:";
  26. cin>>x1;
  27. cout<<"Enter the Y Cordiante";
  28. cin>>y1;
  29. }
  30. void draw()
  31. {
  32. line(x,y,x1,y1);
  33. }
  34. };
  35. class circ:public s1
  36. {
  37. public:
  38. int r;
  39. void get1()
  40. {
  41. cout<<"Enter the radius";
  42. cin>>r;
  43. }
  44. void draw()
  45. {
  46. circle(x,y,r);
  47. }
  48. };
  49. class rect:public s1
  50. {
  51. public:
  52. int w;
  53. void get1()
  54. {
  55. cout<<"Enter the width";
  56. cin>>w;
  57. }
  58. void draw()
  59. {
  60. rectangle(x-w,y-w,x+w,y+w);
  61. }
  62. };
  63. void main()
  64. {
  65. int gd=DETECT ,gm,ch;
  66. initgraph(&gd,&gm,"s:\\appl\\tcplus\\include");
  67. do
  68. {
  69. cout<<"Shapes Menu"<<endl;
  70. cout<<"1.Line"<<endl;
  71. cout<<"2.Circle"<<endl;
  72. cout<<"3.Rectangle"<<endl;
  73. cout<<"4.Exit"<<endl;
  74. cout<<"Enter your choice";
  75. cin>>ch;
  76. switch(ch)
  77. {
  78. case 1:
  79. clrscr();
  80. lineq l1;
  81. l1.getda();
  82. l1.get();
  83. s1 *ptr;
  84. ptr=&l1;
  85. clrscr();
  86. ptr->draw();
  87. getch();
  88. break;
  89. case 2:
  90. clrscr();
  91. circ c1;
  92. c1.getda();
  93. c1.get1();
  94. ptr=&c1;
  95. clrscr();
  96. ptr->draw();
  97. getch();
  98. break;
  99. case 3:
  100. clrscr();
  101. rect r1;
  102. r1.getda();
  103. r1.get1();
  104. ptr=&r1;
  105. clrscr();
  106. ptr->draw();
  107. getch();
  108. break;
  109. case 4:
  110. exit(0);
  111. }
  112. cout<<"press any key to continue";
  113. getch();
  114. clrscr();
  115. }
  116. while(1);
  117. }
Your replies are highly appreciated. Thanking you,

Regds,
Beuls
Last edited by Dave Sinkula; Jan 11th, 2006 at 2:25 pm. Reason: Fixed [code][/code] tags.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 353
Reputation: Asif_NSU is on a distinguished road 
Solved Threads: 3
Asif_NSU's Avatar
Asif_NSU Asif_NSU is offline Offline
Posting Whiz

Re: Graphics in Microsoft C

 
1
  #2
Jan 11th, 2006
graphics.h wont work with Visual C++. You have to learn win32 APIs.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,672
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Graphics in Microsoft C

 
0
  #3
Jan 11th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 40
Reputation: beuls is an unknown quantity at this point 
Solved Threads: 2
beuls beuls is offline Offline
Light Poster

Re: Graphics in Microsoft C

 
0
  #4
Jan 17th, 2006
Originally Posted by Ancient Dragon
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 40
Reputation: beuls is an unknown quantity at this point 
Solved Threads: 2
beuls beuls is offline Offline
Light Poster

Re: Graphics in Microsoft C

 
0
  #5
Jan 17th, 2006
Thx

Beuls
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 3400 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC