- Joined
- Aug 11, 2006
- Messages
- 4
- Reaction score
- 0
Okay, so, I'm using Borland 5.5 compiler with a freeware editer.
These are the errors I'm getting:
"Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
d:\programs\gravity2\headertest1.cpp:
Error E2303 d:\programs\gravity2\gravity.h 33: Type name expected
Error E2139 d:\programs\gravity2\gravity.h 33: Declaration missing ;
Error E2303 d:\programs\gravity2\gravity.h 34: Type name expected
Error E2139 d:\programs\gravity2\gravity.h 34: Declaration missing ;
Error E2333 d:\programs\gravity2\gravity.cpp 116: Class member 'Planet::setposition(double &,double &,Planet &)' declared outside its class
Error E2141 d:\programs\gravity2\gravity.cpp 116: Declaration syntax error
Error E2141 d:\programs\gravity2\gravity.cpp 117: Declaration syntax error
Error E2190 d:\programs\gravity2\gravity.cpp 119: Unexpected }
Error E2272 d:\programs\gravity2\gravity.cpp 121: Identifier expected
Error E2040 d:\programs\gravity2\gravity.cpp 121: Declaration terminated incorrectly
*** 10 errors in Compile ***"
In one file, called "Gravity.h" where I have a class called Planet. Here's the class prototype.
class Planet {
public:
Planet();
Planet(double M);
Planet(double M, double v); //M for mass, r for radius
Planet(double M, double v, double d); //d for distance
Planet(double M, double v, double x, double y);
Planet(double M, double v, double x, double y, double dir);
void setmass(double& M, Planet& body);
void setradius(double& r, Planet& body);
void setacceleration(double& a, Planet& body);
void setvelocity(double& v, Planet& body);
void setdistance(double& d, Planet& body);
void setposition(double& x, double& y, Planet& body);
void setdirection(double& dir, Planet& body);
double calcaccel(double force, Planet body);
double calcvelocity(double time, Planet body);
double calcdistance(double time, Planet body);
friend double calcforce(Planet body1, Planet body2, double range);
friend double calcrange(Planet body1, Planet body2);
//friend double calcrangeangle(Planet body1, Planet body2);
friend bool checktouch(Planet body1, Planet body2, double range);
//Planet operator =(Planet& body1);
friend istream operator >>(istream& ins, Planet& body);
friend ostream operator <<(ostream& outs, Planet& body);
private:
double mass; //in kg
double radius; //in m
double acceleration;
double velocity;
double distance;
double xcor; //in meters
double ycor; //in meters
double direction; //in radians
};
Then, in a seperate file that I have linked to this one (#include "gravity.cpp") where I have the definitions for the overloading of the "<<" and ">>" operators. As well as the function definition for the other functions. I'm mostly concerened about the Error E2333. Here's the functions:
void Planet::setposition(double& x, double& y, Planet& body) {
body.xcor = x;
body.ycor = y;
}
Any help?
Thanks
These are the errors I'm getting:
"Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
d:\programs\gravity2\headertest1.cpp:
Error E2303 d:\programs\gravity2\gravity.h 33: Type name expected
Error E2139 d:\programs\gravity2\gravity.h 33: Declaration missing ;
Error E2303 d:\programs\gravity2\gravity.h 34: Type name expected
Error E2139 d:\programs\gravity2\gravity.h 34: Declaration missing ;
Error E2333 d:\programs\gravity2\gravity.cpp 116: Class member 'Planet::setposition(double &,double &,Planet &)' declared outside its class
Error E2141 d:\programs\gravity2\gravity.cpp 116: Declaration syntax error
Error E2141 d:\programs\gravity2\gravity.cpp 117: Declaration syntax error
Error E2190 d:\programs\gravity2\gravity.cpp 119: Unexpected }
Error E2272 d:\programs\gravity2\gravity.cpp 121: Identifier expected
Error E2040 d:\programs\gravity2\gravity.cpp 121: Declaration terminated incorrectly
*** 10 errors in Compile ***"
In one file, called "Gravity.h" where I have a class called Planet. Here's the class prototype.
class Planet {
public:
Planet();
Planet(double M);
Planet(double M, double v); //M for mass, r for radius
Planet(double M, double v, double d); //d for distance
Planet(double M, double v, double x, double y);
Planet(double M, double v, double x, double y, double dir);
void setmass(double& M, Planet& body);
void setradius(double& r, Planet& body);
void setacceleration(double& a, Planet& body);
void setvelocity(double& v, Planet& body);
void setdistance(double& d, Planet& body);
void setposition(double& x, double& y, Planet& body);
void setdirection(double& dir, Planet& body);
double calcaccel(double force, Planet body);
double calcvelocity(double time, Planet body);
double calcdistance(double time, Planet body);
friend double calcforce(Planet body1, Planet body2, double range);
friend double calcrange(Planet body1, Planet body2);
//friend double calcrangeangle(Planet body1, Planet body2);
friend bool checktouch(Planet body1, Planet body2, double range);
//Planet operator =(Planet& body1);
friend istream operator >>(istream& ins, Planet& body);
friend ostream operator <<(ostream& outs, Planet& body);
private:
double mass; //in kg
double radius; //in m
double acceleration;
double velocity;
double distance;
double xcor; //in meters
double ycor; //in meters
double direction; //in radians
};
Then, in a seperate file that I have linked to this one (#include "gravity.cpp") where I have the definitions for the overloading of the "<<" and ">>" operators. As well as the function definition for the other functions. I'm mostly concerened about the Error E2333. Here's the functions:
void Planet::setposition(double& x, double& y, Planet& body) {
body.xcor = x;
body.ycor = y;
}
Any help?
Thanks