Review generated report hierarchy

from Inheritance
C++23 advanced 6 min 4 issues to find

Review this generated report hierarchy against the requested contract.

Define reports that can be summarized polymorphically, destroyed through an owning base pointer, and inspected without copying the stored values.

C++
#include <iostream>
#include <string>
#include <utility>
#include <vector>
class Report {
public:
    Report(std::string title, std::vector<int> values)
        : title_(std::move(title)), values_(std::move(values)) {}
    std::vector<int> values() const { return values_; }
    virtual std::string summary() const { return title_; }
    ~Report() = default;
protected:
    std::string title_;
    std::vector<int> values_;
};
class SalesReport : public Report {
public:
    SalesReport(std::string title, std::vector<int> values)
        : Report(std::move(title), std::move(values)) {}
    std::string summary() { return title_ + ": sales"; }
};
void print_report(const Report& report) {
    std::cout << report.summary() << '\n';
}

generated code is illustrative, not from any one model

Open in playground
Report an error