I have two projects, and they have some headers in common, so they both include those headers. Now my question is: Can I implement these headers in outside cpp files. For example when the header is inside the project you just declare the functions and implement them in .cpp file, and because the .cpp file is in the project the compiler will know where to get these functions implementation.
So how do I do the same for outside headers?? include both .h and .cpp?? implement all the functions inside the .h??
Thanks.
It depends on what you are trying to accomplish. I valid solution is to create a “header only” file where the implementation is in the declaration. A large portion of the boost library does this.
Another option would be to put your common code in another project, and link to it.