"declaration syntax error"

Susan Stitt susan at nps.gov
Thu Feb 24 10:17:59 EST 1994


This came across the grass-u list, but looks like it was 
intended for the programmers list...  Perhaps you have already 
seen it?

--------------------included message------------------------

From: "wadada" <AGYEI at net2.eos.uoguelph.ca>
Organization:  School of Engineering
Sender: grass-lists-owner at max.cecer.army.mil
Reply-To: grassu-list at max.cecer.army.mil
Sender: grass-lists-owner at moon.cecer.army.mil.
Reply-To: grassp-list at moon.cecer.army.mil.
Precedence: Bulk
To: grassu-list at max.cecer.army.mil
Date: Sat, 19 Feb 1994 18:28:46 EDT
Subject:       "declaration syntax error"
Reply-To: agyei at net2.eos.uoguelph.ca
Priority: urgent
Message-Id: <F7AE461066 at hal2010.nw.uoguelph.ca>

hello c programmers,

i keep on getting the error message 'declaration systax error' in an 
attempt of using Borland Turbo c++ built-in Project Manager to 
compile multi-file programs. i am very possitive there are no errors 
in the source files since they are just sample programs which came 
with the software. i get the same error message for any set of 
program files that i use and the error is always in the header file 
(*.h). the number of such errors i get is always the same as the 
number of BASE and DERIVED class declarations in any header file 
included in the project. i will appreciate it if some could run and 
link the source code below. it comprises a header file (point.h), an 
initialization file (point. CPP) and the main program (pixel.CPP). 
if anyone succeeds in making it work, please try and give me the 
directions. i have been trying for weeks now!! thanks in advance for 
your time.

/* point.h -- sample exercise which came with software */

enum Boolean {false, true};

class Location {
protected:      //allows derived class to access private data
    int X;
    int Y;
    
public:      // these functions can be accessed from outside
    Location(int InitX, initY);
    int GetX();
    int GetY();
};
class Point: public Location { // derived from class Location
//public derivation means that X and Y are protected within Point

protected 
    Boolean Visible; // classes derived from Point will need access
 public:
 Point(int InitX, int InitY);
 void Show();
 void Hide();
 Boolean IsVisible();
 void MoveTo(int NewX, int NewY);
 };       
----------------------------------------------------------------

----------------------------------------------------------------    
/* POINT2.CPP -- sample file which came with software */

# include "point.h"
# include <graphics.h>

// member functions for the Location class

Location::Location(int X, int Y) {
    X=InitX;
    Y=InitY;
};
int Location::GetX(void) {
    return X;
};

int Location::GetY(void) {
    return Y;
};

// member functions for the Point class

Point: Point(int InitX, int InitY) : Location(InitX,InitY) {
    Visible = false;
};

void Point::Show(void) {
    Visible = true
    putpixel(X,Y, getcolor());
};

void Point::Hide(void) {
    Visible = false;  // make invisible by default
    putpixel(x,y, getbkcolor());
};

Boolean Point::IsVisible(void) {
    return visible;
};

void Point::MoveTo(int NewX, int NewY) {
    Hide(); //make current point invisible
    X=NewX; //change X and Y coordinates to new location
    Y=NewY; 
    Show(); // show point at new location
 };
---------------------------------------------------------------------- 

---------------------------------------------------------------------- 
 /* Pixel.CPP demonstates the Point and Location classes
 // compile with POINT2 and link with GRAPHICS.LIB
  
#include <graphics.h>  //declarations for graphics library
#include <conio.h>    //for getche() function
#include "point.h"   //declarations for Point and Location classes

int main()
{
    //initialize the graphics system
    int graphdriver = DETECT, graphmode;
    initgraph(&graphdriver, &graphmode, "c:..\\bgi");
    
    //please what is the meaning of "c:..\\bgi"
    //i have never come accross its explanation in
    //the users guide
    
// move a point across the screen
    Point APoint(100, 50);        //initial X,Y at 100, 50
    Apoint.Show();               // Apoint turns itself on
    getche();                   //  Wait for keypress
    APoint.MoveTo(300,150);    //   Apoint moves to 300, 150
    getche();                  //   Wait for keypress
    closegraph();              //   Restore original screen
    return 0;
}  
--------------------------------------------------------------------

 
                
                








More information about the grass-dev mailing list