• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Dev C++ Multiple files and problem with compiling

Steelerz37

Senior member
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
 
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.
 
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.
 
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.
 
Back
Top