online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include "Location.cpp" #include "hitman.cpp" #include "friend.cpp" #include "fight.cpp" #include <stdlib.h> #include <time.h> using namespace std; string mhitclass = "N/A"; string mfriclass = "N/A"; string mfightlocation = "N/A"; int main() { cout << "Hello and welcome to Mikes Farms! Lets begin our Journy." << endl; Location obj1; obj1.locchoice(); mfightlocation = obj1.outlocation; Hitman obj2; obj2.hitmantype(); mhitclass = obj2.typeout; Friend obj3; obj3.friendtype(); mfriclass = obj3.typeout; Fight obj4; obj4.fightlocation = obj1.outlocation; obj4.hitclass = obj2.typeout; obj4.friclass = obj3.typeout; obj4.combatscript(); // EXAMPLE SECTION BELOW JUST IGNORE FOR REFERENCE ONLY // srand(time(NULL)); // int number = (rand()%10)+1; // cout << number; return 0; }
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; class Hitman{ public: string type1 = "Melee"; string type2 = "Ranger"; string type3 = "Magic"; int input = 0; string typeout = "N/A"; void hitmantype(){ cout << "Time to set a hitman class. Choose from the current selection." << endl; cout << "[1]Melee\n[2]Range\n[3]Magic" << endl; cin >> input; switch(input){ case 1: cout << "You selected the " << type1 << " class." << endl; typeout = type1; break; case 2: cout << "You selected the " << type2 << " class." << endl; typeout = type2; break; case 3: cout << "You selected the " << type3 << " class." << endl; typeout = type3; break; } }; };
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; class Friend{ public: string type1 = "Melee"; string type2 = "Ranger"; string type3 = "Magic"; int input2 = 0; string typeout = "N/A"; void friendtype(){ cout << "Time to select your friends class. Choose from the current selection." << endl; cout << "[1]Melee\n[2]Range\n[3]Magic" << endl; cin >> input2; switch(input2){ case 1: cout << "You selected the " << type1 << " class." << endl; typeout = type1; break; case 2: cout << "You selected the " << type2 << " class." << endl; typeout = type2; break; case 3: cout << "You selected the " << type3 << " class." << endl; typeout = type3; break; } }; };
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; class Location{ public: string loc1 = "Guam"; string loc2 = "Japan"; string loc3 = "Canada"; string loc4 = "Paris"; char start = '!'; int index = 0; string outlocation = "N/A"; void locchoice(){ srand(time(NULL)); cout << "Your Location will be selected at random. Type in ! to begin" << endl; cin >> start; if(start = '!'){ cout << "*Places hand in bag with random names. Pulls out a slip of paper." << endl; index = (rand()%4)+1; switch (index) { case 1: cout << "Congradulations you are going to " << loc1 << "." << endl; outlocation = loc1; break; case 2: cout << "Congradulations you are going to " << loc2 << "." << endl; outlocation = loc2; break; case 3: cout << "Congradulations you are going to " << loc3 << "." << endl; outlocation = loc3; break; case 4: cout << "Congradulations you are going to " << loc4 << "." << endl; outlocation = loc4; break; }; }; } };
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; class Fight{ public: string hitclass = "N/A"; string friclass = "N/A"; string fightlocation = "N/A"; double hit1 = 0; double hit2 = 0; double hit3 = 0; double fri1 = 0; double fri2 = 0; double fri3 = 0; double hitfinal = 0; double frifinal = 0; //Stats hitman int str1 = 0; int att1 = 0; int def1 = 0; int ran1 = 0; int mag1 = 0; int hp1 = 0; //Stats of friend int str2 = 0; int att2 = 0; int def2 = 0; int ran2 = 0; int mag2 = 0; int hp2 = 0; void combatscript(){ (srand(time(NULL))); //first class calculated if(hitclass == "Melee"){ str1 = 87; str1 = str1 + ((rand()%6)+1); str1 = str1 + ((rand()%6)+1); att1 = 87; att1 = att1 + ((rand()%6)+1); att1 = att1 + ((rand()%6)+1); def1 = 87; def1 = def1 + ((rand()%6)+1); def1 = def1 + ((rand()%6)+1); hp1 = 87; hp1 = hp1 + ((rand()%6)+1); hp1 = hp1 + ((rand()%6)+1); hit1 = (str1+att1+def1); hit1 = hit1 + (hp1*3); hit1 = hit1 * 0.05050505; }; if(hitclass == "Ranger"){ ran1 = 87; ran1 = ran1 + ((rand()%6)+1); ran1 = ran1 + ((rand()%6)+1); def1 = 87; def1 = def1 + ((rand()%6)+1); def1 = def1 + ((rand()%6)+1); hp1 = 87; hp1 = hp1 + ((rand()%6)+1); hp1 = hp1 + ((rand()%6)+1); hit2 = (ran1) + (def1*2); hit2 = hit2 + (hp1*3); hit2 = hit2 * (0.05050505); }; if(hitclass == "Magic"){ mag1 = 87; mag1 = mag1 + ((rand()%6)+1); mag1 = mag1 + ((rand()%6)+1); def1 = 87; def1 = def1 + ((rand()%6)+1); def1 = def1 + ((rand()%6)+1); hp1 = 87; hp1 = hp1 + ((rand()%6)+1); hp1 = hp1 + ((rand()%6)+1); hit3 = (mag1); hit3 = hit3 + (def1*2); hit3 = hit3 +(hp1*3); hit3 = hit3 * (0.05050505); }; //secound class calculated if(friclass == "Melee"){ str2 = 87; str2 = str2 + ((rand()%6)+1); str2 = str2 + ((rand()%6)+1); att2 = 87; att2 = att2 + ((rand()%6)+1); att2 = att2 + ((rand()%6)+1); def2 = 87; def2 = def2 + ((rand()%6)+1); def2 = def2 + ((rand()%6)+1); hp2 = 87; hp2 = hp2 + ((rand()%6)+1); hp2 = hp2 + ((rand()%6)+1); fri1 = (str2+att2+def2); fri1 = fri1 +(hp2*3); fri1 = fri1*(0.05050505); }; if(friclass == "Ranger"){ ran2 = 87; ran2 = ran2 + ((rand()%6)+1); ran2 = ran2 + ((rand()%6)+1); def2 = 87; def2 = def2 + ((rand()%6)+1); def2 = def2 + ((rand()%6)+1); hp2 = 87; hp2 = hp2 + ((rand()%6)+1); hp2 = hp2 + ((rand()%6)+1); fri2 = (ran2); fri2 = fri2+(def2*2); fri2 = fri2+(hp2*3); fri2 = fri2*(0.05050505); }; if(friclass == "Magic"){ mag2 = 87; mag2 = mag2 + ((rand()%6)+1); mag2 = mag2 + ((rand()%6)+1); def2 = 87; def2 = def2 + ((rand()%6)+1); def2 = def2 + ((rand()%6)+1); hp2 = 87; hp2 = hp2 + ((rand()%6)+1); hp2 = hp2 + ((rand()%6)+1); fri3 = (mag2); fri3 = fri3+(def2*2); fri3 = fri3+(hp2*3); fri3 = fri3*(0.05050505); }; if(hitclass == "Melee"){ hitfinal = hit1; }; if(hitclass == "Magic"){ hitfinal = hit2; }; if(hitclass == "Ranger"){ hitfinal = hit3; }; if(friclass == "Melee"){ frifinal = fri1; }; if(friclass == "Magic"){ frifinal = fri2; }; if(friclass == "Ranger"){ frifinal = fri3; }; cout << "First person has a max hit of "<< hitfinal << endl; cout << "Second person has a max hit of "<< frifinal << endl; cout << "Stats of first person " << str1 <<" || "<< att1 <<" || "<< def1 <<" || "<< ran1 <<" || "<< mag1 <<" || "<< hp1 << endl; cout << "Stats of Second person " << str2 <<" || "<< att2 <<" || "<< def2 <<" || "<< ran2 <<" || "<< mag2 <<" || "<< hp2 << endl; cout << "Time to Fight!" << endl; cout << "========================================" << endl; } };

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue