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.

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?

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.

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

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?

The one in Dev-C++. (not sure what its called)

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/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.