coates@uc780.umd.edu (06/25/91)
/************************************************************************ * LINE.CPP * * * * Uses POINT.CPP and POINT.H to draw a pixel wide horizontal * * line across the screen. * * ************************************************************************/ #include <graphics.h> // declarations for graphics library #include <conio.h> // 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 * **************************************************************************
coates@uc780.umd.edu (06/25/91)
The Subject: should actually read: "C++ Does Allow Identifier Declaration and Definition Simultaneously" This is demonstrated by the fragment: in main() Line ALine(1, 150); here ALine is an instantiation of Line. It is here declared and defined simultaneously. One could argue that the type 'Line' has already been declard, so that everything is kosher. Any other mistyped reference to 'Line' or 'ALine' would be flagged by the linker. ************************************************************************** * Elliott Coates, washington dc * * coates@uc780.umd.edu * * coates@uc780.bitnet * **************************************************************************
coates@uc780.umd.edu (06/25/91)
Sorry, I sent the code listing by mistake, but once I discovered it was sent, I posted the "take note of this" messsge. Sorry, I sent the code listing by mistake, but once I discovered it was ************************************************************************** * Elliott Coates, washington dc * * coates@uc780.umd.edu * * coates@uc780.bitnet * **************************************************************************
divo@hp-vcd.HP.COM (Mark Divittorio) (06/25/91)
/ hp-vcd:comp.windows.ms.programmer / coates@uc780.umd.edu / 12:29 am Jun 25, 1991 / Sorry, I sent the code listing by mistake, but once I discovered it was sent, I posted the "take note of this" messsge. Sorry, I sent the code listing by mistake, but once I discovered it was ************************************************************************** * Elliott Coates, washington dc * * coates@uc780.umd.edu * * coates@uc780.bitnet * ************************************************************************** ----------