User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,990 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,296 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 217 | Replies: 6
Reply
Join Date: Apr 2008
Location: PLANET EARTH
Posts: 33
Reputation: Dannyo329 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Dannyo329's Avatar
Dannyo329 Dannyo329 is offline Offline
Light Poster

Linking Between C++ Files

  #1  
Jun 4th, 2008
What i'm trying to do is, basically, link one C++ File, to another. For example, first i have a cpp file, like, main. And I want to have a part where the user chooses something then the other cpp file opens.
Greetings Earthlings, I am your PROGRAMMER.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,574
Reputation: niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough 
Rep Power: 8
Solved Threads: 159
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: Linking Between C++ Files

  #2  
Jun 4th, 2008
How do you mean 'the other cpp file opens'?
Do you want function to be called from another CPP-file, or do you want the user to view the cpp-file's contents?
do NOT pm me for help, it makes me angry. You wouldn't like me when I'm angry...
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,561
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Linking Between C++ Files

  #3  
Jun 4th, 2008
Just guessing here, but do you want main() to call a function that is another *.cpp file? For example,
// foo.cpp
#include <iostream>
int foo()
{
    std::cout << "Hello World\n";
    return 0;
}
// main.cpp
extern int foo();
int main()
{
    foo();
    return 0;
}

Now you have to compile main.cpp and foo.cpp then link the object files together to get a single executable program. Exactly how to do that depends on the compiler you are using because each one is different.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Apr 2008
Location: PLANET EARTH
Posts: 33
Reputation: Dannyo329 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Dannyo329's Avatar
Dannyo329 Dannyo329 is offline Offline
Light Poster

Re: Linking Between C++ Files

  #4  
Jun 11th, 2008
Yeah, Thats exactly what I want, but how do you link the object files together to make a single executable program? And when I tried making the two files, and putting the code on to them, it didn't work.

Thanx
Greetings Earthlings, I am your PROGRAMMER.
Reply With Quote  
Join Date: Nov 2007
Posts: 833
Reputation: mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough 
Rep Power: 4
Solved Threads: 170
mitrmkar mitrmkar is offline Offline
Practically a Posting Shark

Re: Linking Between C++ Files

  #5  
Jun 11th, 2008
Originally Posted by Dannyo329 View Post
Yeah, Thats exactly what I want, but how do you link the object files together to make a single executable program? And when I tried making the two files, and putting the code on to them, it didn't work.

Thanx


What compiler are you using?
Reply With Quote  
Join Date: Apr 2008
Location: PLANET EARTH
Posts: 33
Reputation: Dannyo329 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
Dannyo329's Avatar
Dannyo329 Dannyo329 is offline Offline
Light Poster

Re: Linking Between C++ Files

  #6  
Jun 12th, 2008
The one in Dev-C++. (not sure what its called)
Greetings Earthlings, I am your PROGRAMMER.
Reply With Quote  
Join Date: Nov 2007
Posts: 833
Reputation: mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough 
Rep Power: 4
Solved Threads: 170
mitrmkar mitrmkar is offline Offline
Practically a Posting Shark

Re: Linking Between C++ Files

  #7  
Jun 12th, 2008
Originally Posted by Dannyo329 View Post
The one in Dev-C++. (not sure what its called)

Well I take that you use the Dev-C++ IDE, so add the files to your project (create a new project, if you don't have one). Adding an existing file to project is done via Project/Add to Project menu. Once you have all required files you can build the project.

Here are some basic instructions ...
http://csjava.occ.cccd.edu/~gilberts/devcpp5/
Last edited by mitrmkar : Jun 12th, 2008 at 5:08 am. Reason: added link
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 9:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC