I am a student taking a C++ class. I have a program that the instructor wants us to put the source code in many files, for example: mainprogram.cpp, myclass.h, myclass.cpp. Myclass.h is a header file that contains a class, and myclass.cpp is a file that contains the class function definitions.
I have put the include statement for myclass.h at the beginning of the mainprogram.cpp file, and now I don't know how to compile the files. I tried “g++ mainprogram.cpp ,yclass.cpp” but it doest see any of the functions in the file myclass.cpp.
I read the man page for g++, but wasn't able to find any helpful information on the subject.
I did one thing that got everything to compile, but this isn't how the instructor wants us to do it. I put #include “myclass.cpp” at the top of the mainprogram.cpp file, then just did a g++mainprogram.cpp and it worked.
I hope I was able to explain what I want to know clear enough so that someone can help me; if not you can email me at firstname.lastname@example.org
and i will try to explain it again.
The school uses Red Hat Linux in the lab, but i dont know what version, or the version of the gcc compiler.
Any help will be appriciated.