Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!socrates.umd.edu!uc780.umd.edu!coates From: coates@uc780.umd.edu Newsgroups: comp.windows.ms.programmer Subject: C++ Does Allow Identifier Declar & Define Message-ID: <24JUN91.20520720@uc780.umd.edu> Date: 24 Jun 91 20:52:07 GMT Sender: news@socrates.umd.edu (News) Organization: The University of Maryland University College Lines: 75 /************************************************************************ * LINE.CPP * * * * Uses POINT.CPP and POINT.H to draw a pixel wide horizontal * * line across the screen. * * ************************************************************************/ #include // declarations for graphics library #include // for getch() #include "point.h" // declarations for Point and Location classes // Line class declaration class Line : public Point { public: Line(int InitX, int InitY); void Show(void); void DrawLine(int NewX, int NewY); }; // Line class definition Line::Line(int InitX, int InitY) : Point(InitX, InitY) // constructor { }; void Line::Show(void) // make point visible { Visible = true; putpixel(X, Y, getcolor()); }; void Line::DrawLine(int NewX, int NewY) // draw horizontal line { X = NewX; Y = NewY; while (X != 700) { X = ++NewX; Y = NewY; Show(); } }; // Line main int main() { // initialize the graphics system int graphdriver = DETECT, graphmode; initgraph(&graphdriver, &graphmode, "d:\\borlandc\\bgi"); // draw a dot Line ALine(1, 150); // initial X, Y at 1, 150 ALine.Show(); // draw horizontal lines across the screen ALine.DrawLine(1, 150); ALine.DrawLine(1, 225); getch(); // close graphics routines closegraph(); return (0); }; ************************************************************************** * Elliott Coates, washington dc * * coates@uc780.umd.edu * * coates@uc780.bitnet * **************************************************************************