473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 = functionFromProjectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromProjectB (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 1226
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 = functionFromProjectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromProjectB (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 = functionFromProjectB (10);
return i;
}
and in project B:
fileX.cpp:
int functionFromProjectB (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**********************@hotmail.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
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...
4
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...
0
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.