473,804 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

1 solution, 2 projects: how to use function form project B into project A

hello,

i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromPro jectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromPro jectB (int i)
{
return i * 4;
}

i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.

Dec 18 '06 #1
2 1236
unknown; wrote:
hello,

i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromPro jectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromPro jectB (int i)
{
return i * 4;
}

i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.
unknown;:

Are you related to IUnknown?

The easiest thing to do is just to add fileX.cpp to both projects. Of
course that means it will be compiled twice if you change it (unless you
make the output directories the same).

David Wilkinson

Dec 18 '06 #2
i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromPro jectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromPro jectB (int i)
{
return i * 4;
}

i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.
Hi,

References are only useful for .NET projects.
If the second project is a library project, simply make it a dependency
of your other project and include the appropriate header files.

If the projects are not related in that way, you can simply add the
appropriate cpp file to your project.
That way the file gets compiled twice.

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Dec 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2271
by: Tim | last post by:
Dear All, I have been working with VB.NET for the last 5 months or so as a solo developer for a small business. I have already started developing the application but have hit a snag with the referencing of one project within another. I would like to develop the solution using a modular approach such that the solution will be made up of several smaller projects being referenced by a main application project. Some of these smaller
4
6327
by: Brian | last post by:
Hello - Ive got a single "Solution" with two projects. While working with Project2, when I hit F5 to run and debug, the main form from Project1 loads. What is up with this? I thought that while in the same solution, the two projects are completely seperate. Obviously not. Can someone explain what is happening here? And how to I configure it so that Project2's main form loads when I F5. Many thanks!
0
1570
by: Chris Morse | last post by:
Hi, I am creating a solution with two projects. Basically, they share a few common class files and forms. I finished one project, and it compiles and runs fine. I just finished bringing in the second project, and I get the following error on one of the forms when it is invoked: ----------------------------------------------------------------- An unhandled exception of type
5
1346
by: Ohad weiss | last post by:
Hi all, I have a class in project A. At the same solution, I have another project - named project B. I want to write a piece of code in that class from project B that finds the class in project A. How can I do that? I have a code to do that, if the class is in the same project (by using Application.ProductName, but even if I chaned it to the second project name,
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.