Multiple .cpp files problem

Hello, using code::blocks I created a project called exercise for practice purpose. But working on a .cpp files different from the first one created give error 'cause int main() is already in the first file.
How can I avoid this? It sick me to create a complete new project for every exercise, I just wanna use a single project with a single .cpp for every exercise.
Is this possible?
Is this possible?

Yes, as long as there is only one function named main(). I suggest that before you start a new program you save the current .cpp file with a name that reflects the purpose of the file. For example after doing exercise 1 save the file as exercise1.cpp. Then close that file and then reopen the original "main" file, delete everything and then start your new program.

But it might be much easier to just create a new project with a name reflective of the assignment. Then you can always go back and easily look at the previous projects.

closed account (48T7M4Gy)
I haven't use Code::blocks for a while but IIRC it is essentially the same as VStudio and Xcode in that you need only create a single project and remove/add/drag files to that project rather than delete any.

Of course any particular project setup can only have one main().

Last edited on
Topic archived. No new replies allowed.