How To Create A Project In Dev C++
Making Projects with Dev - C++
Hello, i've had a question to ask anyone willing to help me.
I've tried to work on some random project, and when i compiled it, the compiler sent an error message saying
ERROR : Multiple use of main() function
and dosn't compile.
what have I done wrong?
Last edited on
You have the function main more than once in your program. It is used as entry point so you can only one function callen 'main'
but what if my project has multiple .cpp files in it?
like two different programs that when started with the
| |
Last edited on
1 project = 1 program
If you want a second program, create a second project.
Multiple cpp files can be used to spread the code for one program across several files, but it's still only one program.
Ok, so if thats the case, if your spreading code across .cpp files, don't they need a main function too?
or is it an extention of your' program? as in leaving off in your .cpp and continuing in the same spot in another file?
like this :
.cpp file #1
| |
.cpp file #2
| |
No.
main() is the entry point -- it's where your program starts. Your program can't start in more than one place, so you can't have more than one main() in your program.
Multiple source files keep the code organized by having code that does a specific job in one file, and keeping unrelated code in other files. It also speeds up compile time because you don't have to recompile the entire program when you change one source file.
They're not used as your example. Instead, you put different function bodies in .cpp files.
| |
| |
| |
In C++, usually a class has it's own h file for it's class definition, and its own cpp file for its member functions.
Last edited on
So what your saying is, other .cpp files in a project are used to contain functions that you wouldn't want hanging around in a mess in a single file?
Topic archived. No new replies allowed.
How To Create A Project In Dev C++
Source: http://www.cplusplus.com/forum/general/13002/
Posted by: garciahiphell.blogspot.com

0 Response to "How To Create A Project In Dev C++"
Post a Comment