943,805 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5093
  • C++ RSS
Jan 11th, 2006
0

Graphics in Microsoft C

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 13
Solved Threads: 2
Light Poster
beuls is offline Offline
40 posts
since Jan 2006
Jan 11th, 2006
1

Re: Graphics in Microsoft C

graphics.h wont work with Visual C++. You have to learn win32 APIs.
Reputation Points: 113
Solved Threads: 3
Posting Whiz
Asif_NSU is offline Offline
353 posts
since Apr 2004
Jan 11th, 2006
0

Re: Graphics in Microsoft C

Quote ...
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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Jan 17th, 2006
0

Re: Graphics in Microsoft C

Quote 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
Reputation Points: 13
Solved Threads: 2
Light Poster
beuls is offline Offline
40 posts
since Jan 2006
Jan 17th, 2006
0

Re: Graphics in Microsoft C

Thx

Beuls
Reputation Points: 13
Solved Threads: 2
Light Poster
beuls is offline Offline
40 posts
since Jan 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Passing variables around in a MFC project
Next Thread in C++ Forum Timeline: C++ arrays and random numbers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC