online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
// Diego Zamudio hh726 #include <iostream> #include <string> #include <vector> #include "Car.h" class Inventory { private: std::vector<Car> cars_; public: void printInventory() const { for (std::size_t i = 0; i < cars_.size(); i++) { const Car& car = cars_[i]; std::cout << " " << (i + 1) << ". " << car.getCategory() << ": " << car.getMake() << " " << car.getModel() << " (" << car.getAge() << ")\n"; } } int getSize() const { return static_cast<int>(cars_.size()); } const Car& getCar(int index) const { return cars_[static_cast<std::size_t>(index)]; } void addCar(const Car& car) { cars_.push_back(car); } void sellCar(int index) { cars_.erase(cars_.begin() + index); } }; int main() { Inventory inventory; inventory.addCar(Car("Ford", "F-150", "Truck", "New")); inventory.addCar(Car("Cheverolet", "Equinox", "Truck", "New")); inventory.addCar(Car("Honda", "Civic", "Car", "New")); inventory.addCar(Car("Nissan", "Altima", "Car", "New")); inventory.addCar(Car("Toyota", "Corolla", "Car", "New")); inventory.addCar(Car("Ford", "Fusion", "Car", "Old")); inventory.addCar(Car("Cheverolet", "Impala", "Car", "Old")); inventory.addCar(Car("Honda", "Accord", "Car", "Old")); inventory.addCar(Car("Nissan", "Rogue", "Car", "Old")); inventory.addCar(Car("Toyota", "RAV4", "Truck", "Old")); inventory.printInventory(); return 0; }
#pragma once #include <string> class Car { private: std::string make_; std::string model_; std::string category_; std::string age_; public: Car(); Car(const std::string& make, const std::string& model, const std::string& category, const std::string& age); void setMake(const std::string& make); const std::string& getMake() const; void setModel(const std::string& model); const std::string& getModel() const; void setCategory(const std::string& category); const std::string& getCategory() const; void setAge(const std::string& age); const std::string& getAge() const; };
#include "Car.h" Car::Car() : make_("empty"), model_("empty"), category_("empty"), age_("empty") {} Car::Car(const std::string& make, const std::string& model, const std::string& category, const std::string& age) { setMake(make); setModel(model); setCategory(category); setAge(age); } void Car::setMake(const std::string& make) { make_ = make; } const std::string& Car::getMake() const { return make_; } void Car::setModel(const std::string& model) { model_ = model; } const std::string& Car::getModel() const { return model_; } void Car::setCategory(const std::string& category) { category_ = category; } const std::string& Car::getCategory() const { return category_; } void Car::setAge(const std::string& age) { age_ = age; } const std::string& Car::getAge() const { return age_; }

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