When ever I create a new program in Xcode(c family language) the main file created works perfectly fine in compiling the code and running it but when I create a new c++ file in the same program then Xcode just shows a duplicate error while compiling it(the code is fine, I checked it). After this the main file also shows a similar error. What to do? I am a beginner.
You have to create a new project in Xcode for each program you write.
Creating a new project for each program is annoying when learning a language and writing small programs. I recommend using a text editor such as TextMate, BBEdit, or Visual Studio Code for learning C++. TextMate has a bundle that will let you run your programs from inside the editor. Visual Studio Code probably has an extension to run your programs inside the editor. I'm not sure if BBEdit has a way to run your programs from the editor.
Creating a new project for each program is annoying when learning a language and writing small programs. I recommend using a text editor such as TextMate, BBEdit, or Visual Studio Code for learning C++. TextMate has a bundle that will let you run your programs from inside the editor. Visual Studio Code probably has an extension to run your programs inside the editor. I'm not sure if BBEdit has a way to run your programs from the editor.