Can you call another .cpp file be called in another .cpp file
I want to choose Single player or Multiplayer but not have a crap ton of code between the if else if else. Or is there a better way to go about doing this?
(sorry if the code is sloppy, its just to show you what I would like to do.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
cout << "how many players are there? (1/2)" << endl;
cin >> gamemode;
if (gamemode = 1)
{
//call singleplayer.cpp
}
elseif (gamemode = 2)
{
// call multiplayer.cpp
}
else
{
cout << "Not a Valid Answer!"
}
The std::cout is a variable that is neither declared nor implemented within this file.
The << is a function that is likewise "in some other .cpp".
Both are declared in the header file names "iostream". By including the "iostream" in our .cpp we know the names and types of those objects/functions and can then use them.
You could code the multiplayer and singleplayer differently. then make the launcher cpp. build all of them, then run the launcher.exe which open multiplayer or singleplayer and then closing the launcher program
Like this:
1 2 3 4 5
int gamemode=0;
cin>>gamemode;
if (gamemode==1){
system("singleplayer.exe");
}