views:

135

answers:

1
+3  Q: 

Shared Code Layout

Hi,

I have two C++ projects in a solution both of which need to share two common classes. What I want to avoid is having two copies of the source files but I am relucant to just include the source in one project and reference it in the other.

How is this sort of situation normally handled?

+13  A: 

Create a third project, which is either a dynamic or static library (prefer the latter for ease of use) and put the shared code in there. The two other projects #include the headers from the library project and link with library project binary.

anon
Thanks for the answer, could you point me to any code examples or articles so I can get to grips with this?
Konrad
What development environment are you using?
anon
Visual Studio 2008 for Win32.
Konrad