TIP: Utilizing Solutions and Projects in VS 2005 | CodeGuru

TIP: Utilizing Solutions and Projects in VS 2005

As programmers we try to improve productivity—re-using existing codes or libraries is a must. In its simplest form, a library could arrive in the form of two files, such as widget.h and widget.lib, that can be included and linked into your new application. Alternatively, they might arrive as a source code that can be added […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 22, 2009
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

As programmers we try to improve productivity—re-using existing codes or libraries is a must. In its simplest form, a library could arrive in the form of two files, such as widget.h and widget.lib, that can be included and linked into your new application. Alternatively, they might arrive as a source code that can be added to your application. This sounds simple enough except that this code might be updated regularly and you will want to keep it separate in a folder—as a standalone project in Visual Studio.

This leads to the topic of this article. How you can utilize projects in a VS2005 solution to keep everything nicely organized?

For this tutorial, let’s just say you have received the two files (tools.h and tools.cpp) as listed below and you want to be able to call add() and minus() in your application. Obviously, real libraries would probably have hundreds of functions rather than just the couple shown here. Last but not least, your application (MyApp.cpp) would call the two functions.

tools.h:
———————————————————–

int add(int a, int b);
int minus(int a, int b);

tools.cpp:
———————————————————–

#include "tools.h"

int add(int a, int b)
{
   int c;
   c = a+b;
   return c;
}

int minus(int a, int b)
{
   int c;
   c = a-b;
   return c;
}

MyApp.cpp:
———————————————————–

#include <iostream>
#include "..toolstools.h"
using namespace std;

int main(int argc, char* argv[])
{
   int p,q;
   p = add(10,3);
   q = minus(10,3);
   cout << "Testing tool box library.n";
   cout << "p=" << p << " q=" << q << endl;
   return 0;
}
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.