Reputation: 149
Please submit only one zip file .Your zip file should contain the following files:
How is it possible to turn in 2 cpp files? Does that mean I am gonna have 2 different projects and combine them into one? I understand classes, but I am unsure how they could be all used in a zip file.
Note: I am not looking for code; I am looking for understanding. Maybe someone has done something similar? this is a grocery list with integers instead of items.
Upvotes: 0
Views: 315
Reputation: 106096
- ItemListClass.h
- ItemListMethods.cpp
- ItemListTests.h
- ItemListTests.cpp
- makefile
- numbers.txt
This implies that ItemListClass.h provides the caller-visible interface for your ItemList, that the out-of-line implementation for the member functions of ItemList go in ItemListMethods.cpp, and that a test program (presumably with a main()
function in ItemListTests.cpp) will exercise the ItemList functionality. I can see no particular reason to think that ItemListTests.h is useful... whatever ItemListTests could credibly contain is unlikely to be of use to any code other than ItemListTests.cpp, and if it was then it should really be moved into a "TestSupport.h" header or similar. But, the implication is that ItemListMethods.cpp should include ItemLists.h, and ItemListTests.cpp should include ItemListTests.h. numbers.txt is presumably input data that your ItemListTests.cpp will read through to populate an ItemList object during testing. The makefile should do something vaguely like:
ItemListTest: <tab> ItemList.o ItemListTest.h ItemListTest.cpp
<tab>g++ -g -o ItemListTest ItemList.o ItemListTest.cpp
ItemList.o: <tab> ItemList.h ItemList.cpp
<tab>g++ -g -c ItemList.cpp
You can then type "make" in the same directory to build an executable ItemListTest
.
Upvotes: 2
Reputation: 2590
A project in almost all C++ IDEs/compilers is allowed to have multiple source files. Typically you couldn't compile them from the zip file unless they are extracted. The reason they ask for a zip is because it is very easy to send/submit. It would have to be extracted after your instructor/examiner receives it.
Upvotes: 1
Reputation: 40603
C++ supports a concept called "separate compilation".
Basically, each .cpp file can be compiled independently from all the others, and the final program is made by "linking" all of the compiled files together.
Upvotes: 4
Reputation: 8644
You should read about makefiles.
Basically, your makefile is the project you're submitting and is made up by four files.
Upvotes: 1
Reputation: 137810
Each .cpp
file implements a set of functions. The entire program is the union of those functions… the compiler (specifically the "linker", which is the last stage of the compiler) gathers the functions together and packages it into your executable.
A project usually contains numerous .cpp
files. C++ has few rules about how the program is divided over them, but usually each contains one class or group of functions.
Header files exist so that each .cpp
file can be aware of the functions defined in the others.
Upvotes: 2