Compile Error...any help?

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
 
Joined
Jul 4, 2006
Messages
11
Reaction score
0
please check this first.

1) (#include "gravity.cpp") it should be #include "gravity.h"
2) friend istream &operator >>(

please check the difference and understand global friend function concepts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top