|
아래 코드들은 도스용 코드들입니다.
윈도우에 콘솔 모드는 비슷해 보이지만.. 정확히는 도스모드가 아닙니다.
따라서 기존 도스명령들은 사용할수 없습니다.
방법은 도스로 부팅시켜서 Borland C++ 3.1등으로 컴파일해야 합니ㅏㄷ.
모라 님이 쓰신 글 :
: 아래 소스가 c++관련 소스인데
:
: c++빌더 6의 콘솔 위자드 모드로 해볼려니 에러가 뜨면서 안되더군요.
:
: 특히 graphics.h에서 에러가 잡히던데......
:
: 콘솔 모드에서 아랫 소스가 컴파일이 될까요?
:
: c++빌더란에다 할려니 c++에 더 가까운것 같기도 해서, 여기다 질문을 드립니다.
:
: --EX19-4.CPP 부분--
:
: #include <iostream.h>
: #include <graphics.h>
: #include <conio.h>
: #include <stdlib.h>
: #include <dos.h>
: #include "EX19-3.h"
: class Circle:public Point {
: private:
: int Rad;
: public:
: Circle(int,int,int,int);
: void Show();
: void Hide();
: void Moveto(int,int);
: void Resize(int);
: int GetRad() { return Rad;}
: };
: Circle::Circle(int x,int y,int c,int r):Point(x,y,c)
: {
: Rad=r;
: }
: void Circle::Show()
: {
: Visible=true;
: setcolor(Color);
: circle(px,py,Rad);
: }
: void Circle::Hide()
: {
: Visible=false;
: setcolor(getbkcolor());
: circle(px,py,Rad);
: }
: void Circle::Moveto(int nx,int ny)
: {
: Hide();
: px=nx;
: py=ny;
: Show();
: delay(50);
: }
: void Circle::Resize(int nr)
: {
: Hide();
: Rad=nr;
: delay(50);
: Show();
: }
: void main()
: {
: int gd=0,gm;
: initgraph(&gd,&gm,"");
: Circle WON(100,200,14,50); // 원 객체 생성
: WON.Show(); // 객체의 출력
: for (int i=0;i<30;i++) // 객체의 이동
: WON.Moveto(WON.Getpx()+5,WON.Getpy());
: for (int j=0;j<50;j++) // 객체의 크기 변경
: WON.Resize(WON.GetRad()+3);
: getch();
: closegraph();
: }
:
:
: --EX19-3.h부분--
: #include <iostream.h>
: #include <graphics.h>
: #include <conio.h>
: #include <stdlib.h>
: #include <dos.h>
: enum Boolean {false,true};
: class Position { // 기반 class정의
: protected:
: int px,py;
: public:
: Position(int,int);
: int Getpx() {return px;}
: int Getpy() {return py;}
: };
: class Point:public Position { // 파생 class정의
: protected:
: int Color;
: Boolean Visible;
: public:
: Point(int,int,int);
: int Getcolor() {return Color;}
: Boolean Getvisible() {return Visible;}
: void Show();
: void Hide();
: void Moveto(int,int);
: };
: Position::Position(int x,int y)
: {
: px=x;
: py=y;
: }
: Point::Point(int x,int y,int c):Position(x,y)
: {
: Color=c;
: Visible=false;
: }
: void Point::Show()
: {
: Visible=true;
: putpixel(px,py,Color);
: }
: void Point::Hide()
: {
: Visible=false;
: putpixel(px,py,getbkcolor());
: }
: void Point::Moveto(int nx,int ny)
: {
: Hide();
: px=nx;
: py=ny;
: Show();
: delay(100);
: }
:
|