Hi, can someone help me out? I've been plagued by this one problem all day and I don't know what to do about it.
I'm trying to break everything up into separate files because I want to be able to reuse some of the classes I'm creating, right? So, I have Color.h and Color.cpp, plus both files for Body and both files for Sphere which extends Body, and finally both files for Cinfo, which is basically a class solely used to pass lots of information between stuff at the same time so the program doesn't have to repeat the equations, which are kind of costly but give lots of information at once when they're done.
Cinfo has a constructor which looks like this:
1 2 3 4 5
|
Cinfo::Cinfo (float di, float ti, Color ci) {
d = di;
t = ti;
c = ci;
}
|
I've overloaded the = operator for Color and tested that independently and I know it works.
Body has a function that looks like this:
1 2 3
|
Cinfo Body::collision(Vector3d c) {
return Cinfo(-1, -1, Color(0, 0, 0));
}
|
Obviously this is not the final code for determining collisions, but I just want to make sure everything works first.
Finally, Sphere, which extends Body, has:
1 2 3
|
Cinfo Sphere::collision(Vector3d c) {
return Cinfo(1, 1, Color(255, 255, 255));
}
|
So essentially all it should do right now when trying to check collisions is return two -1s and the color black on a default Body and two 1s and the color white if that Body is a Sphere in particular. However, when I try to compile, I get the following:
1 2 3 4 5 6
|
In function `Body::collision(Vector3d)':
Body.cpp:(.text+0x5a): undefined reference to `Cinfo::Cinfo(float, float, Color)'
classes/Sphere.o: In function `Sphere::collision(Vector3d)':
Sphere.cpp:(.text+0xc8): undefined reference to `Cinfo::Cinfo(float, float, Color)'
collect2: ld returned 1 exit status
make: *** [main] Error 1
|
Of course, my Body.h includes Cinfo.h, and of course Sphere includes it also by virtue of extending Body. I have triple-checked my spellings and capitalizations on all files and headers and function calls in both the .h's and the .cpp's. Any ideas?