I am new to c++ programming. I do not have any idea of oop in c++. But I only know the basics like loops, if else structures and switch-case statements. I have decided to write Tic-Tac-Toe in c++. Its too large without Object Oriented Programming. But still I decided to do that. After fixing a bunch of errors, I am getting this error: "Multiple definitions of the same function" and I have no idea how to fix this. I am using four files altogether (in code::blocks). The main file:
//main.cpp
//Tic-Tac-Toe game
#include <iostream>
#include "Untitled1.cpp"
#include "Untitled2.cpp"
#include "Untitled3.cpp"
using namespace std;
int main()
{
cout << "HII\nWelcome to Tic-Tac-Toe!!!\nEnter 1 to play with yourself\nEnter 2 to play with someone who's with you\nEnter 3 to play with the computer ";
string num;
krrish:
cin >> num;
// <EXCEPTION HANDLING>
while ((num != "1") && (num != "2") && (num != "3"))
{
cout << "I guess you didn't understand!!\n\nEnter 1 to play with yourself\nEnter 2 to play with someone who's with you\nEnter 3 to play with the computer ";
goto krrish;
}
// </EXCEPTION HANDLING>
if (num == "1")
{
playwithyourself();
}
else if (num == "2")
{
playwithanotherone();
}
else if (num == "3")
{
playwithcomputer();
}
return 0;
}
In this file I have used three other files containing the functions declared above. Untitled1.cpp:
#include <iostream>
using namespace std;
int playwithyourself()
{
/////4828 LINES OF CODE INSIDE; TOOK ME WEEKS TO WRITE THIS; ITS LONG COZ I DUNNO OOP
}
Untitled2.cpp
#include <iostream>
using namespace std;
int playwithanotherone()
{
//Left empty haha, not written yet
}
Untitled3.cpp
#include <iostream>
using namespace std;
int playwithcomputer()
{
//Left empty haha, not written yet
}
When I am compiling main.cpp its showing this error for the three functions:"multiple definition of '(function name)'" And its also showing this error: "1d returned 1 exit status" Seriously I am messed up.