|
From: <san...@ya...> - 2003-08-27 20:34:16
|
Hi!
I don't want to say anything stupid, for I'm new to
the list, but, if I'm not mistaken :
* when you will compile (button with four color
squares / Ctrl+F9), Dev-C++ will expect your project
to have one and only one "main" function. If you have
created a console based project, the .cpp file created
at the same time as the project already has one.
* so, if your multiple .cpp files correspond to
multiple programs (each .cpp file has a "main"
function), you must create a different project for
each .cpp file (one project per file). You will
compile each project separately, hence execute each
.cpp file separately.
* if these multiple .cpp files only hold functions,
you must :
- call these functions within your "main" function ;
- precise to Dev-C++ where these functions can be
found.
A simple way (though not the best one) to do this is
to use the "extern" directive. This could look like
this (we have 3 files, named main.cpp, test1.cpp and
test2.cpp) :
main.cpp
========
#include <iostream>
#include <stdlib.h>
extern void test1(void);
extern void test2(void);
using namespace std;
int main(int argc, char *argv[])
{
test1();
test2();
system("PAUSE");
return 0;
}
test1.cpp
=========
#include <iostream>
using namespace std;
void test1(void)
{
cout << "Test1" << endl;
}
test2.cpp
=========
#include <iostream>
using namespace std;
void test2(void)
{
cout << "Test2" << endl;
}
A better way to do, would be to declare each function
within a header file (test.h, or test.hpp).
I hope I've answered your question. If you want me to
be more precise, just ask. Now, if I've misinterpreted
your question, please forgive me!
Bye! Sandy/Moonlight
--- "Nadesan, Binu" <bna...@ci...> a écrit :
> Hi All,
>
> I have created a console based project using the
> Dev-C++ IDE. The project
> contains multiple
> .cpp files. Each of these files are small sample
> .cpp files. Now how do I
> execute one of the .cpp file.
>
>
> With Best Regards...
> Binu Nadesan
> bna...@ci... <mailto:bna...@ci...>
> Tel#: (513) 612-2206
>
>
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
|