Dev C++ Multiple files and problem with compiling

Steelerz37

Senior member
Feb 15, 2003
693
0
0
Hello,
I am writing a student report generator that has 3 classes in it:
Person.h and Person.cpp
Student.h and Student.cpp
Course.h and Course.cpp

they are defined as such: Student is a person(by inheritance) and Student has a dynamic array of Course objects.

My classes all work great but my problem comes when I try to compile from main only, or from a project that only has Student.h and Student.cpp. It gives me errors that it basically can not find he person stuff or the course stuff. I have all the apprpriate #include "xxxx.h" in the appropritate places. I will not be penalized for having all the class headers and definitions in the project but I am unsure as to why using my includes do not work as I expect them to. All implementation is done in the cpp files. Any help would be much appreciated. Thanks.

Ben
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
It sounds like your compiler isn't getting the include path. On the command line it would be something like g++ -c student.cpp -I/path/to/my/include/files
Can't help you with how your IDE does that.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
On the command line it would be something like g++ -c student.cpp -I/path/to/my/include/files

Which shouldn't be necessary as long as the include files are in the same directory as the file including them.
 

Steelerz37

Senior member
Feb 15, 2003
693
0
0
yea, the headers and cpp files are all in the same folder, which I though would work, and it seemed to work on an earlier assignment, but maybe I added the header and source to the project for that assignment as well.

I think i was taking this for granted but maybe the problem just because I include Student.h, how does anything know that my code is in Student.cpp? Because I just copied my code from Student.cpp to Student.h and pasted it under the class definition and it seemed to work and gave me Person errors instead of the Student errors it had been giving me.