online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include "Manager.h" static void PrintHierarchy(const Company::Manager * manager) { std::cout << manager->GetName() << std::endl; for (Company::TeamLead * teamLead : manager->GetTeamLeads()) { std::cout << '\t' << teamLead->GetName() << std::endl; for (Company::Programmer * programmer : teamLead->GetProgrammers()) { std::cout << "\t\t" << programmer->GetName() << std::endl; } } } int main() { Company::Manager manager("Charles Manager", 0); Company::TeamLead teamLead_A("Alpha Lead", 1); Company::TeamLead teamLead_B("Bravo Lead", 2); Company::Programmer programmer_A0("John Alpha", 3); Company::Programmer programmer_A1("Jane Alpha", 4); Company::Programmer programmer_A2("Jeffrey Alpha", 5); Company::Programmer programmer_B0("Amos Bravo", 6); Company::Programmer programmer_B1("Ane Bravo", 7); Company::Programmer programmer_B2("Amy Bravo", 8); Company::Programmer programmer_B3("Arthur Bravo", 9); manager.Add(&teamLead_A); manager.Add(&teamLead_B); teamLead_A.Add(&programmer_A0); teamLead_A.Add(&programmer_A1); teamLead_A.Add(&programmer_A2); teamLead_B.Add(&programmer_B0); teamLead_B.Add(&programmer_B1); teamLead_B.Add(&programmer_B2); teamLead_B.Add(&programmer_B3); PrintHierarchy(&manager); return 0; }
#pragma once #include <string> namespace Company { class Programmer { private: std::string _name; unsigned int _id; float _hoursWorked; public: Programmer(std::string name, unsigned int _id); const std::string & GetName() const; unsigned int GetId() const; void Work(float hours); }; }
#include "Programmer.h" namespace Company { Programmer::Programmer(std::string name, unsigned int id) : _name(name), _id(id), _hoursWorked(0.0f) { } const std::string & Programmer::GetName() const { return _name; } unsigned int Programmer::GetId() const { return _id; } void Programmer::Work(float hours) { _hoursWorked += hours; } }
#pragma once #include <string> #include <vector> #include "Programmer.h" namespace Company { class TeamLead { private: std::vector<Programmer *> _programmers; std::string _name; unsigned int _id; float _hoursWorked; public: TeamLead(std::string name, unsigned int _id); const std::string & GetName() const; unsigned int GetId() const; void Work(float hours); void Add(Programmer * programmer); const std::vector<Programmer *> & GetProgrammers() const; }; }
#include "TeamLead.h" namespace Company { TeamLead::TeamLead(std::string name, unsigned int id) : _name(name), _id(id), _hoursWorked(0.0f) { } const std::string & TeamLead::GetName() const { return _name; } unsigned int TeamLead::GetId() const { return _id; } void TeamLead::Work(float hours) { _hoursWorked += hours; } void TeamLead::Add(Programmer * programmer) { _programmers.push_back(programmer); } const std::vector<Programmer *> & TeamLead::GetProgrammers() const { return _programmers; } }
#pragma once #include <string> #include <vector> #include "TeamLead.h" namespace Company { class Manager { private: std::vector<TeamLead *> _teamLeads; std::string _name; unsigned int _id; float _hoursWorked; public: Manager(std::string name, unsigned int _id); const std::string & GetName() const; unsigned int GetId() const; void Work(float hours); void Add(TeamLead * teamLead); const std::vector<TeamLead *> & GetTeamLeads() const; }; }
#include "Manager.h" namespace Company { Manager::Manager(std::string name, unsigned int id) : _name(name), _id(id), _hoursWorked(0.0f) { } const std::string & Manager::GetName() const { return _name; } unsigned int Manager::GetId() const { return _id; } void Manager::Work(float hours) { _hoursWorked += hours; } void Manager::Add(TeamLead * teamLead) { _teamLeads.push_back(teamLead); } const std::vector<TeamLead *> & Manager::GetTeamLeads() const { return _teamLeads; } }

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