I am working on a static library project for a C ++ course that I am taking. The teacher insists that we define only one function for the source file, grouping the files / functions belonging to one class in subdirectories for each class. This leads to a structure such as:
MyClass
\MyClass.cc (constructor)
\functionForMyClass.cc
\anotherFunctionForMyClass.cc
OtherClass
\OtherClass.cc (constructor)
Whether this is good practice or not, this is something I would not want to discuss, as I simply have to organize my project in this way.
I work in visual studio 2008 and somehow get weird link errors when using the same named function (and thus the file name) in two classes. This, apparently, is due to the fact that the visual studio places all the files .obj(one for each source file) in one intermediate directory, overwriting previously created object files when compiling files with identical names.
This can be solved by placing the object files in subdirectories based on the relative path of the input file. Visual studio allows you to customize the names of the object files it creates and use macros there, but there is no macro for the "relative path of the input file".
So, is there a way to make this work? If not, does one project use the best way to work for each class?