36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
/// @file
|
|
/// @brief task B
|
|
/// g++ -g -fsanitize=address -std=c++20 taskB.cpp -o taskB && ./taskB
|
|
|
|
#include <vector>
|
|
|
|
#include "taskB.Device.hpp" // Device
|
|
|
|
#include "taskB.Train.hpp" // Train : Device
|
|
#include "taskB.WashingMachine.hpp" // WashingMachine : Device
|
|
|
|
#include "taskB.Car.hpp" // todo: implement Car : Device
|
|
|
|
int main() {
|
|
|
|
std::vector<Device*> devices; ///< contains pointers to dynamically allocated objects
|
|
|
|
devices.push_back(new WashingMachine("Miele W1", "will last forever (if you maintain it well)", 1500, 1200));
|
|
devices.push_back(new WashingMachine("Constructa XZY", "will also last forever (if you maintain it well)", 500, 800));
|
|
devices.push_back(new Train("ICE 4", "solid and fast train", 820, 350));
|
|
devices.push_back(new Train("Railjet I", "one of the world fastest trains with a discrete locomotive", 400, 200));
|
|
|
|
/// @todo: create dynamically allocated instances of your Car/Train classes and push them to 'devices'
|
|
|
|
|
|
/// loop over the vector and making use of the interface function 'print_info'
|
|
for (const auto& d : devices) {
|
|
d->print_info();
|
|
}
|
|
|
|
/// @todo: delete all dynamically allocated objects stored in 'devices' using 'delete' (use a loop)
|
|
|
|
|
|
return 0;
|
|
}
|