"declaration syntax error"

wadada AGYEI at net2.eos.uoguelph.ca
Sat Feb 19 17:28:46 EST 1994


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-user mailing list