Question:
i created multiple files but when i run a file then its showing that error.
Replit Profile: https://replit.com/@shouryapratik
Question:
i created multiple files but when i run a file then its showing that error.
Replit Profile: https://replit.com/@shouryapratik
Can you give us the link to the repl?
We need the file structure or code to further examine the problem and assist you
If I created multiple c++ files in a folder and when I open a single file and click on run then shown error.
But when I comments out other files and then run or delete other files then run it runs
@shouryapratik To have more that 1 .cpp file, use .hpp files and the main .cpp file.
Hope this helps!
I’m not quite experienced in CPP but I can help you a bit, if I’ve said anything wrong feel free to correct me
If you see the error message, it says multiple definition of ‘main’
In the code, at the time I access it, book allocation.cpp
is empty since you commented everything out, it does nothing to the code.
However in another.cpp
and painter.cpp
you both defined ‘main’, the program doesn’t know which main entrypoint should it use, thus this error.
You can fix this by deleting all reference to main(), and add only 1 main in one of the file
Means I can’t run code
When I created multiple files…
I have to delete other files of comments out to run…
But in vs code I don’t have to do much …
Same error…
U try first then confirm…
What if it was int somethingelse {
in the hpp files?
Or you could try and modify this script to work with running C. You’d probably have to replace .replit
with Makefile
, and modify this regex (which looks for the position in the file where the file to run is specified)