Does my "Static Library" approach appear to be valid, or may I run into problems later on?
Looks about right. Can't see anything that would cause a problem (other than if you start moving directories around, etc).
Debugging may be hindered by the lack of source code for Foo
's implementation, making it harder to use. Of course, you can always supply the source file and a debug build of the library, in which case this particular problem "goes away".
Is the second approach valid? Will it create problems later? I guess one cons is that I cannot hide part of the implementation in a lib file, and have to supply both source and header instead of lib and header.
Would be valid (in the sense that you can include other source code from another project into your current project - it's no longer, technically, a "static library"), yes (the user may need to add the Foo.cpp
file to the project as well - and any other file that the project includes. If Foo
and it's parts is a lot of files, this could be a major drawback.
Aside from having to supply sources, you also increase the compile time for the entire project (at least when built from scratch). This may not be an issue for a small project, but larger projects can take quite some time to build.
A plus is of course that the user of the functinality in class Foo
can step into the source and debug it when something goes wrong.
Is there any pros and cons of each methods?
Answered above, I think.