Ask coding questions

← Back to all posts
When I add a 2nd file, I get an error and my code doesn't run on that file.
EdwardGomez

Hello everyone,
I just started using repl.it and so far its great for a quick coding program!

I am using it for a C++ class and the professor gives us multiple examples to note down.
When I create a new repl and use the main.cpp file I type
#include <iostream>
using namespace std;
int main() {
then I begin to code the example. But when I try to add a new file and start with the same beginning 3 lines of code it gives me an error when running the code it says: /tmp/number-76d309.o: In function main': number.cpp:(.text+0x0): multiple definition ofmain'
/tmp/age-f5685b.o:age.cpp:(.text+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
compiler exit status 1

Does anyone know how to bypass this? It would be cool to make new files for each coding example the professor gives us.

Thanks for the help!

Voters
trexk
smart1146
DDiazfigueredo
EdwardGomez
Comments
hotnewtop
theangryepicbanana

You cannot run multiple files in one repl (however you can include them). Just make another C++ repl

EdwardGomez

Damn alright, thank you for the quick reply! @theangryepicbanana

mwilki7

@EdwardGomez
The best you can do is to use c++ threads.
But if you want to run many functions at the same time while getting user input, you won't know which one asked for your age or number first.

But if you really want to run these at the same time try:

If you meant to do it without multi-threading try: