online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <exception> #include <iostream> #include <string> #include <vector> class Person { private: std::string name_; int tasksCompleted_; public: explicit Person(const std::string& name) : name_(name), tasksCompleted_(0) {} const std::string& whoIs() const { return name_; } int numberTasksCompleted() const { return tasksCompleted_; } void performTask() { tasksCompleted_++; } }; int main() { try { std::vector<Person> people{ Person( "Bodine" ), Person( "Finn" ), Person( "Tycho" ) }; // For each person in array const int MAX_TASKS = 7; // Don't like magic numbers! int currentPerson = 0; // Needed variable for (auto& p : people) { std::cout << p.whoIs() << " has performed task #:\n"; while (p.numberTasksCompleted() < MAX_TASKS) { p.performTask(); std::cout << p.numberTasksCompleted() << '\n'; if (p.numberTasksCompleted() == MAX_TASKS) { currentPerson++; if (currentPerson <= (people.size() - 1) ) { std::cout << "It's your turn " << people[currentPerson].whoIs() << " to do some tasks.\n"; } break; } } } } catch( std::runtime_error& e ) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }

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