Mail Archives: djgpp/1997/05/23/02:51:04
George Foot wrote:
> Note the difference between a declaration and a definition; a function
> prototype is a declaration, as is an `extern' variable declaration. I
> expect you already have these in your code, otherwise you'd get compiler
> errors/warnings. The definition of a function is the part which specifies
> its body; the definition of a variable is, for example, `int a;' (without
> an `extern' before it).
>
> Incidentally, if you forget to declare a function, but use it anyway in
> your code, the compiler will attempt to construct a prototype for it,
> usually (thankfully) failing miserably. Make sure that the functions in
> file3.cc which you want to make available to other files are indeed
> correctly prototyped in appropriate header files.
>
Ok, let me explain the problem a bit more in detail:
My program(an astrophysics project) consists of the following files:
file1.cc (main program)
file2.h (celestial body classes with alot of inline functions)
file2.cc (implementation of the above)
vector.h (vector class with some inline functions +
implementation and 5 friend functions without
implementation)
vector.cc(implementation of the above friend functions)
The functions that are giving me trouble are two of the above mentioned
friend functions. In vector.h is written
friend vector X_Rotation(vector a, double
alfa); friend vector Y_Rotation(vector a, double
alfa);
friend vector Z_Rotation(vector a, double alfa);
These functions represent a rotation of the vector a around the X(Y orZ)
axis over an angle alfa. Vector.cc contains the lines
#include "vector.h"
and the implementation of the above mentioned 3 functions and the 2
others that don't give any trouble.
In file2.cc two of these rotation functions are used in the following
manner:
vector V = X(orZ)_Rotation(W, Angle);
Now I'm pretty sure that this is the place where the undefined reference
error occurs, since this error message only appears for X_Rotation and
Z_Rotation, and not for Y_Rotation, which never gets used in my program.
I can't really see the error here, please explain me what the problem
might be. I hate to keep bothering people with this, but since this is
my first C++ program, I'm quite stuck here. Can't see if it works and
I'm getting very close to my deadline here.
Heeeeeeeeeeeeeeeeeelp!
A.B.
--
Darn right! No government should be allowed to keep a tax-paying, god
fearing citizen from strapping a couple hundred thousand Estes rocket
motors to a kerosene tanker with the hope she'll make orbit. If it
lands on some stupid, third world country, well it serves them right
for not investing in an ABM system!
- Someone in sci.space.policy -
- Raw text -